Jim Hranicky, Senior SysAdmin UF/CISE Department |
E314D CSE Building Phone (352) 392-1499 |
jfh@cise.ufl.edu http://www.cise.ufl.edu/~jfh |
“Given a choice between a complex, difficult-to-understand, disconcerting
explanation and a simplistic, comforting one, many prefer simplistic
comfort if it’s remotely plausible, especially if it involves blaming
someone else for their problems.”
– Bob Lewis, Infoworld
How does this relate to Enumerable#select,
which Array mixes in? Do we somehow get
the functionality of both?
Judging from some 1.7.3 experimenting, it seems that Array#select, if
given an argument, acts like #indices, and if given a block but no
argument, acts like #find_all (for which it used to be a synonym). If
given both, it raises an exception.
I don’t know if this is still under discussion, but in case it is…
This new flavor of #select doesn’t feel to me like it has the right
name. Maybe I’m just used to the idea of select as involving a test,
rather than an index – and in fact it still does, some of the time.
It’s really the same name for two very different things.
My instincts, such as they are, would lead me to lean toward a
multi-arg version of #at:
[1,2,3].at(1,2) => [2,3]
Or is there (not for the first time) a subtlety or two I’m not
getting?
How does this relate to Enumerable#select,
which Array mixes in? Do we somehow get
the functionality of both?
Judging from some 1.7.3 experimenting, it seems that Array#select, if
given an argument, acts like #indices, and if given a block but no
argument, acts like #find_all (for which it used to be a synonym). If
given both, it raises an exception.
I don’t know if this is still under discussion, but in case it is…
This new flavor of #select doesn’t feel to me like it has the right
name. Maybe I’m just used to the idea of select as involving a test,
rather than an index – and in fact it still does, some of the time.
It’s really the same name for two very different things.
My instincts, such as they are, would lead me to lean toward a
multi-arg version of #at:
[1,2,3].at(1,2) => [2,3]
Or is there (not for the first time) a subtlety or two I’m not
getting?