This was how you do things in ruby- there's special syntax for using record arguments as if they were named arguments.
But @jplubin pointed out to me that records don't curry like named arguments can- that's enough of an argument for me!
-
-
is this like Python's "splat" operator for dictionaries, **? (I know 0 Ruby so just trying to relate to what I know.) def foo(arg1, arg2): ... rec = {"arg1": 42, "arg2": 13} foo(**rec)
1 reply 0 retweets 0 likes -
This but in reverse: you can define def foo(args) args[:arg1] ... args[:arg2] ... and then call foo(arg1: 3, arg2: "asdf") which gets desugared to foo({:arg1 => 3, :arg2 => "asdf"})
1 reply 0 retweets 0 likes -
wat
1 reply 0 retweets 0 likes -
Replying to @pl_pierce @alpha_convert and
I... dislike this very very much, I'm sorry
1 reply 0 retweets 0 likes -
But this is the official ruby way, blessed by matz, and optimized for developer enjoyment how can you possibly not like it?
1 reply 0 retweets 1 like -
you're right, I was hasty in my reply and upon further reflection I must admit Ruby as the Language Supreme™
1 reply 0 retweets 2 likes -
Ruby 3 has types, and soon will have pattern matching with an exhaustiveness checker. Embrace the ruby.
1 reply 0 retweets 2 likes -
Python is also adding pattern matching. where is your god now.
1 reply 0 retweets 1 like -
Python is actually insane. You can do wacky bindings at both the call and definition. This is valid: def f(a,b,*x,c=0,d=0,**y): print(a,b,x,c,d,y) f(1, *[2,3], c=3, **{'d':5,'q':6}) It will print out "1 2 (3,) 3 5 {'q': 6}".
2 replies 0 retweets 3 likes
I know this because I once engaged in a Quixotic effort to statically analyze some Python code. It took me 130 LOC just to match arguments between call/definition in a function inliner.https://github.com/willcrichton/inliner/blob/29c53f6bf4c44e452c7bfd66e64743290cd74514/inliner/transforms.py#L32-L161 …
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
cognitive psychology. PhD