Want another challenge? Try implementing all of the Enumerable methods using only reduce. It should be noted that the signature for reduce / inject takes an initial value and does not necessarily assume the first item as the initial accumulator.
As an aside, any? / none? do not iterate every element. They break the second they find an element for which the condition is true where any? returns true and none? returns false.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Want another challenge? Try implementing all of the
Enumerable
methods using onlyreduce
. It should be noted that the signature forreduce
/inject
takes an initial value and does not necessarily assume the first item as the initial accumulator.As an aside,
any?
/none?
do not iterate every element. They break the second they find an element for which the condition istrue
whereany?
returnstrue
andnone?
returnsfalse
.