Closed elyhess closed 4 years ago
Thanks for submitting this @elyhess, as well as the others mentioned who participated in the discussion. In this case, changing this max_by
to a min_by
is an appropriate solution. However, given the name of the exercise, I believe the intent was that every problem in this set can be solved using max_by
. In this case, a solution using max_by could be
found_word = words.max_by do |word|
-1 * word.length
end
By adding in the -1, you are able to sort by shortest length first. While using min_by
would be an appropriate solution, I don't think it is the only solution and thus I don't think a permanent change to the exercises is warranted.
Thanks again for the participation!
I stumbled on what I believe to be a typo in the
fix_using_max_by_test.rb
in theenumerables
folder. I believemax_by
should actually bemin_by
. After consulting with several other students, we came to the consensus that this could very well have been a typo.https://github.com/turingschool/ruby-exercises/blob/386e10e94fe3cc018ae5da654977723b3851ed04/enumerables/exercises_1/find_using_max_by_test.rb#L18-L24
In the thread where we discussed this
Megan Campbell said:
Joe Jiang had replied stating:
with Josh Thompson chiming in at the end
I implemented this fix in PR #83