Created
September 25, 2012 14:55
-
-
Save kachick/3782432 to your computer and use it in GitHub Desktop.
Array 要素すべてが#==で一致するか調べる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
values = [1, 2, 3] | |
others = [1.0, 2.0, 3.0] | |
(values.length == others.length) && values.each_with_index.all?{|v, idx|v == others.fetch(idx)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なるほど、同じArrayの中で、ですか
==による比較では無いのですが、例のようなFixnum等だけが対象だったらuniq活用するのもありかもしれません。