class method
self.[]
Ruby on Rails 3.2.22.5
Since v3.2.22.5 Last seen in v3.2.22.5Signature
self.[](*args)
No documentation comment.
Parameters
-
argsrest
Source
# File activesupport/lib/active_support/ordered_hash.rb, line 73
def self.[](*args)
ordered_hash = new
if (args.length == 1 && args.first.is_a?(Array))
args.first.each do |key_value_pair|
next unless (key_value_pair.is_a?(Array))
ordered_hash[key_value_pair[0]] = key_value_pair[1]
end
return ordered_hash
end
unless (args.size % 2 == 0)
raise ArgumentError.new("odd number of arguments for Hash")
end
args.each_with_index do |val, ind|
next if (ind % 2 != 0)
ordered_hash[val] = args[ind + 1]
end
ordered_hash
end
Defined in activesupport/lib/active_support/ordered_hash.rb line 73
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::OrderedHash