DEV Community

Discussion on: What's a useful programming language feature or concept that a lot of languages don't have?

Collapse
 
cathodion profile image
Dustin King • Edited

It's nice not having to work backwards:

"Take the string, then do x to it, then do y to it"

instead of

"Take the result doing z to the result of doing y to the result of doing x to the string".

I once wrote something to let you do this in Python:

def incd(x, by=1):
    return x + by

print('7 ==', fv(1).incd().incd(2).incd(by=3))
#=>  7 == 7
Enter fullscreen mode Exit fullscreen mode

Python had the idea that methods are just functions (hence having an explicit self parameter), it just didn't take it far enough.