[#74190] [Ruby trunk Feature#12134] Comparison between `true` and `false` — duerst@...
Issue #12134 has been updated by Martin D端rst.
3 messages
2016/03/07
[#74269] Type systems for Ruby — Rob Blanco <ml@...>
Dear ruby-core,
5 messages
2016/03/10
[#74395] [Ruby trunk Feature#12142] Hash tables with open addressing — shyouhei@...
Issue #12142 has been updated by Shyouhei Urabe.
3 messages
2016/03/17
[ruby-core:74268] [Ruby trunk Feature#12165] Hash#first, Hash#last
From:
fabian_stillhart@...
Date:
2016-03-10 18:00:02 UTC
List:
ruby-core #74268
Issue #12165 has been reported by Fabian Stillhart.
----------------------------------------
Feature #12165: Hash#first, Hash#last
https://bugs.ruby-lang.org/issues/12165
* Author: Fabian Stillhart
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
Just run into a simple problem with a colleague and was wondering why there is no Hash#last method?
~~~ruby
{a: true, b: false}.last
NoMethodError: undefined method 'last' for {:a=>true, :b=>false}:Hash
~~~
Interestingly I while playing arround I found out that the Hash#first method works. But why is it not in the ruby-doc?
~~~ruby
{a: true, b: false}.first
=> [:a, true]
~~~
I would assume the Hash#last method would work like the Hash#first method:
~~~ruby
{a: true, b: false}.last
=> [:b, false]
~~~
If I am not wrong the order of a Hash is always the same when calling Hash#each. So wouldn't it make sense to have Hash#last method?
I tested it in Ruby 2.2.4 and Ruby 2.3.0.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>