Ruby

[ruby2.4 クイズ]Enumerable#sum

More than 1 year has passed since last update.

問題

ruby2.4より

([0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1].sum) == (0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1)
#=> ?

:mouse:
:cow:
:tiger:
:rabbit:
:dragon_face:
:snake:
:horse:
:sheep:
:monkey_face:
:bird:
:dog:
:boar:
:mouse:
:cow:
:tiger:
:rabbit:
:dragon_face:
:snake:
:horse:
:sheep:
:monkey_face:
:bird:
:dog:
:boar:

答え

([0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1].sum) == (0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1)
#=> false

([0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1].sum) #=> 1
(0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1)       #=> 0.999...