Hi -- On Fri, 3 Mar 2006, Charlie Bowman wrote: > The only time this nil problem occurs for me is with rails views. With > all other ruby (about half my time is spent in ruby and the other half > web apps) code, I never have the nil problem unless I've written bad > code. I feel like web templates should not throw errors if you pass nil > values. Probably the best thing is to do whatever's necessary in the controller to make sure the template can coast. So you could, for example, put list.items (or whatever) in @items, making sure in advance that it's an empty array if there aren't any. David > > On Fri, 2006-03-03 at 03:07 +0900, Yukihiro Matsumoto wrote: > >> Hi, >> >> In message "Re: cleaner Ruby in a rails view" >> on Fri, 3 Mar 2006 01:38:38 +0900, "Brian Cully" <bcully / gmail.com> writes: >> >> |I would love for ruby's nil to behave properly, as it does in lisp and >> |objc. You can ask nil anything, but all you're going to get back is nil. >> >> Which one behave more properly? Lisp, or Objective-C? Since they >> have different behavior for nil[1]. For your information, you can define >> something like nil in Objective-C by yourself, using the combination >> of BlankSlate and method_missing. Or you can even hack the >> interpreter to make nil behave "properly"[2]. It's pretty easy. >> >> matz. >> >> [1] Try (1+ nil) in your Lisp REPL. In Lisp, nil is just a (), not >> that something which returns nil for every request, like one in >> Objective-C. >> [2] But I'm sure you will soon find out making nil behave like you >> want is a pretty bad idea. Trust me. I did it 10 years ago. It >> swallowed so many errors, and made my debugging horrible. Perhaps >> a separated special value dedicated for the purpose might be >> better. >> > > > Charlie Bowman > http://www.recentrambles.com > -- David A. Black (dblack / wobblini.net) Ruby Power and Light (http://www.rubypowerandlight.com) "Ruby for Rails" chapters now available from Manning Early Access Program! http://www.manning.com/books/black