3 ms·
> users.map {|u| "(" + u.first_name + ")" } If you need to specify the "u" in order to re-use it in one place only, then your language is syntactically challen
by vorg 10y ago
> users.map {|u| "(" + u.first_name + ")" }
If you need to specify the "u" in order to re-use it in one place only, then your language is syntactically challenged. Use a better language instead of caring about the names. A more flexible language would enable a predefined name like "it" or "_" instead, e.g:
users.map{"(" + it.first_name + ")"}
or even provide syntax to do common stuff, e.g. the asterix in:
users*.{"(" + first_name + ")"}
- GregBuchholz 10y agoYou may be interested in "Programming Shorthands" http://research.microsoft.com/apps/pubs/default.aspx?id=69746 http://research.microsoft.com/apps/pubs/default.aspx?id=6974... http://lambda-the-ultimate.org/node/2035 http://lambda-the-ultimate.org/node/2035
- kazinator 10y agoIn a tight scope like this, `u` is the same thing as the classic "dummy variable", like the `i` in a for loop. "For a user u, do this". Dummy variables must never be given long names, because long names say, "this is not a dummy variable", which is a lie in that case.
- robwilliams 10y ago>Use a better language instead of caring about the names. That's not always an option. Also, I don't find the language OP linked syntactically challenged. C# has a similar syntax and it's much more readable than what you've provided: people.Sort(p => p.FirstName);