4 ms·
I thought more languages did this but at least nix and ocaml do not actually behave like I thought. In Ruby however it is a bit more ugly def f x x + 1
by georgyo 4y ago
I thought more languages did this but at least nix and ocaml do not actually behave like I thought.
In Ruby however it is a bit more ugly
def f x
x + 1
end
puts f f 1
> 3
- the_af 4y agoI don't understand your objection, what output would you like to see instead?
- lgessler 4y agoGP's point is that while yes, we know since `f` has arity 1 there's no ambiguity, in general you might not have the arity of any given function fresh in your head, and therefore can't tell (in Ruby) just from looking at `f f 1` whether it means a single invocation of an arity 2 function, or two invocations of an arity 1 function
- the_af 4y agoAh! Right. It helps to have all functions be of arity 1 to disambiguate, yes.