Re:Ask HN: Your favorite syntactic sugar from any language?
by himom on Friday June 15, 2018 @08:29PM
(#17324939)
Swift closure syntax, at least in <= 2.0, made for awkward API calls, since it wasn’t clear whether inline or after closures were used.
In Ruby,
a.map(&:succ)
Re:Ask HN: Your favorite syntactic sugar from any language?
by steveklabnik on Friday June 15, 2018 @08:36PM
(#17324981)
If you have a named function, rust lets you do
a.map(succ)
as well, since functions can be used where closures can, as long as the types work.
Re:Ask HN: Your favorite syntactic sugar from any language?
by jeffmcmahan on Friday June 15, 2018 @08:51PM
(#17325062)
Same in JS
a.map(x => x + 1)
which is pretty nice. And Rust lets you do:
a.map(|x| x + 1)
C++ syntax is just awful, and especially for functional stuff.