Ruby Array and .max

来源:互联网 发布:c语言编程简易小游戏 编辑:程序博客网 时间:2024/05/17 13:41

I'm very confused here.

Why does ["4", "5", "29", "54", "4", "0", "-214", "542", "-64", "1", "-3", "6", "-6"].max

return 6 and not 542

After deleting 6 from the array, then it returns 542

["4", "5", "29", "54", "4", "0", "-214", "542", "-64", "1", "-3", "6", "-6"].max_by(&:to_i)#=> "542"

0 0