Is there a difference between Array#index and Array#find_index? I can’t
see one from reading the docs, but the docs also do NOT say that one
method is just an alias to the other one, so there should be a
difference.
Ronald
Is there a difference between Array#index and Array#find_index? I can’t
see one from reading the docs, but the docs also do NOT say that one
method is just an alias to the other one, so there should be a
difference.
Ronald
The docs aren’t perfect.
When we take alook a the ruby C-source, the comments above the function
rb_ary_index strongly suggest that #index and #find_index are the same.
To confirm this, we ask ruby itself:
a = Array.instance_method :index
b = Array.instance_method :find_index
c = Array.instance_method :rindex
puts a.eql? b # => true
puts a.eql? c # => false
See UnboundMethod#eql?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs