R
Ron M
I find that a bunch of my code looks like
people.map{|person| person.email_addr}
where I use map to apply a single method to elements inside arrays.
That sure beats C, but wouldn't it be nice if there
were a shorthand for doing so. I think something
like this would be very nice:
people[*].email_addr
Even better, I often have strings of such stuff that
looks like this, creating nested arrays
departments.map{|dept| dept.people.map{|person| person.email_addr}}
where a much cleaner alternative would be
departments[*].people[*].email_addr
so the "[*]" operator would descend into nested arrays.
In total ignorance of whether the parser would
allow it, I'd like to say that I think that'd
be a nice addition to ruby2 if there's no other
clean shorthand out there already.
people.map{|person| person.email_addr}
where I use map to apply a single method to elements inside arrays.
That sure beats C, but wouldn't it be nice if there
were a shorthand for doing so. I think something
like this would be very nice:
people[*].email_addr
Even better, I often have strings of such stuff that
looks like this, creating nested arrays
departments.map{|dept| dept.people.map{|person| person.email_addr}}
where a much cleaner alternative would be
departments[*].people[*].email_addr
so the "[*]" operator would descend into nested arrays.
In total ignorance of whether the parser would
allow it, I'd like to say that I think that'd
be a nice addition to ruby2 if there's no other
clean shorthand out there already.