From: sawadatsuyoshi@... Date: 2019-12-19T16:37:05+00:00 Subject: [ruby-core:96341] [Ruby master Misc#16436] hash missing #last method, make it not so consistent (it has first) Issue #16436 has been updated by sawa (Tsuyoshi Sawada). What is this issue? Is it just a note to everyone, or are you claiming this to be a bug, or is it a feature request? ---------------------------------------- Misc #16436: hash missing #last method, make it not so consistent (it has first) https://bugs.ruby-lang.org/issues/16436#change-83249 * Author: zw963 (Wei Zheng) * Status: Open * Priority: Normal * Assignee: ---------------------------------------- ``` ruby (pry):main(0)> h = {x:1, y:2, z:3} { :x => 1, :y => 2, :z => 3 } (pry):main(0)> h.first [ :x, 1 ] (pry):main(0)> h.first.first :x (pry):main(0)> h.first.last 1 ``` last method not exist. ```ruby (pry):main(0)> h.last Exception: NoMethodError: undefined method `last' for {:x=>1, :y=>2, :z=>3}:Hash ``` We have to use #to_a to make last working. ```ruby (pry):main(0)> h.to_a.last [ :z, 3 ] (pry):main(0)> h.to_a.last.first :z (pry):main(0)> h.to_a.last.last 3 ``` -- https://bugs.ruby-lang.org/ Unsubscribe: