Remix.run Logo
usrbinenv 9 hours ago

The only difficulty in Ruby code is the block notation. Even then, it is very similar to constructs in JavaScript, Go, D and a number of other languages -- the only difference form JS would be that instead of `(x) => ...` you write `{ |x| ... }`.

Questions such as

> why does it not have parentheses around it but the `", "` passed to `join` does?

would be exactly the same for JavaScript, Go or D. Ruby has the best syntax with regards to blocks/lambdas/closures.

Qem 2 hours ago | parent | next [-]

> Ruby has the best syntax with regards to blocks/lambdas/closures.

A bit of Smalltalk shining through Ruby.

abenga 9 hours ago | parent | prev [-]

I don't know much Ruby outside of a few toy examples I wrote a long time ago. For most languages, there would be parentheses around objects you pass to functions, like `.filter({|x| x.odd? })`. This lends some consistency and makes it easy (for me at least) to understand that an anonymous function is passed to `filter`. Just separating it using spaces feels like Bash, something I find difficult to write anything slightly complicated in.

creata 7 hours ago | parent [-]

Lua, Haskell, ML, plenty of other languages where one-argument functions don't need parentheses. I think it makes a lot of code more readable.

abenga 6 hours ago | parent [-]

All not-exactly-popular languages.

creata 6 hours ago | parent [-]

Maybe relative to juggernauts like C or Java. But Lua is pretty widely used.

Defletter 3 hours ago | parent [-]

Kotlin too