Hacker News new | ask | show | jobs
by Gravityloss 2639 days ago
Very personal opinion and matter of taste: Many lambda syntaxes are a bit weird.

    map(my_array)element:element*2 //lobster
    my_array.map{|element|element*2} //ruby
    Arrays.stream(my_array).map(element -> element*2).collect(something list something)  //java?
Lobster feels a bit unbalanced. Ruby has "pipes" which are a bit confusing substitute parentheses. Java has the cool arrow syntax but otherwise it feels very glued on. (edited and fixed, thanks for the comment)
1 comments

Your Lobster version has a stray comma, it is: map(my_array) element: element * 2

Note how if you write this example with multiple statements instead of "elements * 2", suddenly the Lobster syntax looks a lot more consistent, and the Ruby example doesn't look that great as it looks completely different from the built-in for loop.

No-one uses the built-in for loop in Ruby though. Instead, everyone uses the each method which looks the same as map.

That said, the Ruby syntax can be a bit bulky. Your syntax feels pretty clean TBH.