4 ms·
> why do you prefer parenthesis-less function calls? I don’t feel strongly about it, but you gotta admit that this is remarkably easy on the eyes yet also easy
by skrebbel 1y ago
> why do you prefer parenthesis-less function calls?
I don’t feel strongly about it, but you gotta admit that this is remarkably easy on the eyes yet also easy to follow:
parts = version_string.to_s.split(”.”).map(&:to_i)
The Elixir equivalent, likely a series of pipes, would be just as easy to follow but substantially more to read, more symbols to parse etc. I don’t feel like this here line of Ruby makes any sacrifices in understandability compared to this Elixir port we’re both imagining.
Good point about grepping though.
- asa400 1y ago> The Elixir equivalent, likely a series of pipes, would be just as easy to follow but substantially more to read, more symbols to parse etc. Huh? [major, minor, patch] = version_string |> String.split(".") |> Enum.map(&String.to_integer/1) I don't know that I'd call this "substantially more" of anything.
- skrebbel 1y agoEnum.map(&String.to_integer/1) vs .map(&:to_i) To me the latter is no less clear so yeah, substantially more. For context I write Elixir once a week and Ruby once a decade. In particular in this case elixir’s (and erlang’s) arity disambiguation (the slash) seems like unhelpful noise. Enum.map only accepts single-arity functions so it seems weird to me that the language couldn't figure that out for me.