On Tue, 03 Jan 2012 06:14:36 -0800, Antoine Musso hashar+wmf@free.fr wrote:
Le Fri, 30 Dec 2011 18:31:30 +0100, Krinkle krinklemail@gmail.com a écrit:
Since virtually any value other than null and undefined is an object, including numbers, strings and functions.
Much like ruby! http://ruby-doc.org/core/Integer.html
$ irb
5.upto( 10 ) { |num| print "#{num}ber," }
5ber,6ber,7ber,8ber,9ber,10ber,=> 5
print 4.even?
true=> nil
You can change the 'even?' behavior to do something else of course :D
;) Oh no, in Ruby EVERYTHING is an object, there is no 'virtually' or 'almost'.
nil.class
=> NilClass
puts "nil is nil" if nil.nil?
nil is nil => nil
nil.is_a? NilClass
=> true
Although, their booleans are awkward.
true.class
=> TrueClass
false.class
=> FalseClass
true.class.superclass
=> Object
false.class.superclass
=> Object Last I checked the way to say "Is this a boolean?" in Ruby was `value === true || value === false`. Ugh.
In JavaScript we have Boolean instead.