This comment is hidden because it contains spoiler information about the solution
Hell yeah, solution like this is wrong:
def check_ages?(data, sex, age_is_greater_than) data.all? { |i| i[:sex] == sex || i[:age] > age_is_greater_than } end
check_ages?([{:age=>40, :sex=>:m}, {:age=>19, :sex=>:m}], :m, 20) will return true instead false
check_ages?([{:age=>40, :sex=>:m}, {:age=>19, :sex=>:m}], :m, 20)
true
false
TIL f.(...) == f.call(...)
f.(...)
f.call(...)
TIL f.(...) is an option. I always use f[...]
f[...]
Ha, didn't know about this. Great solution!
That's why I got it wrong, it needs ALL matched sex to have a superior number!
Incorrectly converts THE-STEALTH-WARRIOR into THESTEALTHWARRIOR instead of into TheStealthWarrior
The task says returns true if all of the items matching the sex value have ages greater than the value provided.
I think the solution in question passes this.
What if all data contain only sex: 'f' and method run with sex: 'm', I think it be wrong.
this is neat :)
Great solution!
Seems matrixMultiplication is still used in default examples that are used when clicking "test" button
Loading collection data...
This comment is hidden because it contains spoiler information about the solution
Hell yeah, solution like this is wrong:
check_ages?([{:age=>40, :sex=>:m}, {:age=>19, :sex=>:m}], :m, 20)
will returntrue
insteadfalse
TIL
f.(...)
==f.call(...)
TIL
f.(...)
is an option. I always usef[...]
Ha, didn't know about this. Great solution!
That's why I got it wrong, it needs ALL matched sex to have a superior number!
Incorrectly converts THE-STEALTH-WARRIOR into THESTEALTHWARRIOR instead of into TheStealthWarrior
The task says returns true if all of the items matching the sex value have ages greater than the value provided.
I think the solution in question passes this.
What if all data contain only sex: 'f' and method run with sex: 'm', I think it be wrong.
this is neat :)
Great solution!
Seems matrixMultiplication is still used in default examples that are used when clicking "test" button