On 9/22/06, Thomas Fuchs <[EMAIL PROTECTED]> wrote: > > hmm-- i've modelled it after the rails ruby extension[1].
Which uses nil. > Note that the german version of the article is much clearer and > mentions the synonymity of null and nil explicitly. I believe the english version has some good points, see below. > So null in JavaScript should be equal to nil in Ruby. There are reasons to say nil in Ruby == undefined in Javascript. The Wikipedia article distinguishes between two meanings: Quote: Null is a special value for a pointer (or other kind of object reference) used to signify that the pointer intentionally does not have a target. [...] Some languages use other nomenclature for such a pointer, e.g., nil, undefined, void reference, etc. => undefined in Javascript, nil in Ruby Quote: In many disciplines, the concept of null allows a three-valued logic, with null indicating "unknown value". => null in Javascript. What about Ruby, does it have something similar? Javascript supports both concepts with null and undefined respectively. Using undefined instead of null makes sure, that you can have an array with members using this three-valued logic. Furthermore: "var foo;" depicts a variable that does not have a value. foo is undefined, not null. And I believe this is what the filler elements are. Array members that do not have a value (that are undefined), because they were not part of the original array. Of cause, you can do arr[3] = undefined;, but still: choosing between null and undefined, undefined seems to carry the meaning better than null. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~---
