Thursday, 15 August 2013

when '=' can be used just after 'if' in Ruby/Rails?

when '=' can be used just after 'if' in Ruby/Rails?

I have noticed this metod, while looking through ActiveModel::Serializable
def as_json(args={})
if root = args[:root] || options[:root]
options[:hash] = hash = {}
options[:unique_values] = {}
hash.merge!(root => serialize)
include_meta hash
hash
else
serialize
end
end
and i really dont know how the 'if root =' works... Shouldn't it be 'if
root =='?

No comments:

Post a Comment