131 reputation
4
bio website
location
age 20
visits member for 2 years, 2 months
seen May 14 at 20:30

I am a php/ruby/rubymotion web/mobile app developer working at ClearSight Studio


Sep
24
awarded  Autobiographer
Nov
29
awarded  Supporter
Nov
2
comment Is it okay to define a [] method in ruby's NilClass?
@Rig, I see how that could be an issue. Thanks for clarifying.
Oct
19
comment Is it okay to define a [] method in ruby's NilClass?
If foo is nil, it will return nil. I'm not seeing the issue. A developer would be able to see that the code inside the if isn't running, and a few more checks could determine a cause.
Oct
19
awarded  Editor
Oct
19
revised Is it okay to define a [] method in ruby's NilClass?
set foo again.
Oct
19
comment Is it okay to define a [] method in ruby's NilClass?
It's not really too much of an issue, I just wondered why, with ruby's penchant for clean code, things like this: if foo && foo["bar"] && foo["bar"]["baz"] && foo["bar"]["baz"]["bang"] are necessary to find out if foo["bar"]["baz"]["bang"] exists when any of the preceding keys could be nil.
Oct
19
awarded  Student
Oct
19
comment Is it okay to define a [] method in ruby's NilClass?
That's true. I was assuming that foo has been set somewhere. If it's undefined, you still have the issue. But by defining [], you have one less issue.
Oct
19
asked Is it okay to define a [] method in ruby's NilClass?