J
Joshua Muheim
Hi all
In PHP I can simply check whether $param['x']['y'] exists regardless
whether $param['x'] exists or not.
In Rails I get a NoMethodError when using
if param[:x][:y]
..
end
when param[:x] is nil. So I always have to use
if param[:x] and param[:x][:y]
..
end
but I think that's not very beautiful - think about a case where I have
to check whether param[:a][:b][:c][:d][:...] exists or not!
Maybe there's a cooler way to do this? ;-)
Thanks
Josh
In PHP I can simply check whether $param['x']['y'] exists regardless
whether $param['x'] exists or not.
In Rails I get a NoMethodError when using
if param[:x][:y]
..
end
when param[:x] is nil. So I always have to use
if param[:x] and param[:x][:y]
..
end
but I think that's not very beautiful - think about a case where I have
to check whether param[:a][:b][:c][:d][:...] exists or not!
Maybe there's a cooler way to do this? ;-)
Thanks
Josh