4 ms·
Rather than an explicit Maybe I've always wanted something built into the language. Why can't the language check for null customers in customer.id? I'd prefer
by goodgoblin 19y ago
Rather than an explicit Maybe I've always wanted something built into the language. Why can't the language check for null customers in customer.id? I'd prefer customer.id to == null if customer is null.
- bhb 19y agoI think the problem is that often you really do want to know if customer is nil. The nice thing about having to explicitly specify this is that you localize the effects - and make it clear in your code that you want this 'pass-through' behavior in a specific part of your code. If you wanted this behavior everywhere, you could just include this code class NilClass def method_missing(method, *args) nil end end But I think this would cause more problems than it would solve.