R
rantingrick
I find the naming conventions for iterators lacking. We use the
exclamation and question marks on our methods to convey more
intuitive meanings however we seemed to have dropped the ball when it
comes to iterators (which take a simple predicate). For instance the
methods:
* select
* reject
* collect
* inject
* detect
Should have had an _if appended to them.
* select_if
* reject_if
* collect_if
* inject_if
* detect_if
The if demands a predicate must follow. numbers.select_if{|x|
predicate}.
Furthermore: the each, each_index, and each_with_index should have
been compiled into one method depending on the local variables in the
block.
rb> [].each{|item| ...}
rb> [].each{|index| ...}
rb> [].each{|item, index| ...}
I find this far more intuitive than having three methods. The fact
that we are iterating over an index, or an item, or enumerating the
collection should NOT be part of the identifier. We can solve this
issue more cleanly and intuitively by looking in the block.
exclamation and question marks on our methods to convey more
intuitive meanings however we seemed to have dropped the ball when it
comes to iterators (which take a simple predicate). For instance the
methods:
* select
* reject
* collect
* inject
* detect
Should have had an _if appended to them.
* select_if
* reject_if
* collect_if
* inject_if
* detect_if
The if demands a predicate must follow. numbers.select_if{|x|
predicate}.
Furthermore: the each, each_index, and each_with_index should have
been compiled into one method depending on the local variables in the
block.
rb> [].each{|item| ...}
rb> [].each{|index| ...}
rb> [].each{|item, index| ...}
I find this far more intuitive than having three methods. The fact
that we are iterating over an index, or an item, or enumerating the
collection should NOT be part of the identifier. We can solve this
issue more cleanly and intuitively by looking in the block.