Re:Ruby 3.0 Preview 1
by rpastuszak on Friday September 25, 2020 @07:42PM
(#24595166)
Arguably, select/where are less familiar than map/filter to many. I'm not saying that either is a standard, but I can imagine the confusion if you come from say, JS background.
To be fair, map/filter wasn't so popular like now when C# 3.0 (released in 2008) was designed.
Not who you’re responding to but from context I would assume map/filter, as he said.
Re:Ruby 3.0 Preview 1
by EdwardDiego on Friday September 25, 2020 @10:01PM
(#24595848)
`where` is intuitive as a synonym for `filter`, but it's the `select` that always threw me as a synonym for `map`.
I get that they're trying to expose an SQL-like API, but yeah, map is always about mutation, but `select`only does mutation sometimes in SQL.
Map doesn't mutate, it returns the result of applying a function to the (possibly immutable) value. I believe you can also, say, `select icolumn * 2 from table`, where `icolumn * 2` provides precisely the same functionality as the function passed to a map.
`Where` at least answers the question "does filter _keep_ the things matching the predicate or _remove_ the things matching the predicate" - my pet hate with the .NET naming is `SelectMany` over `flatmap`.
Which names do you believe are standard?