1. La nature d'un langage
2. Variables et méthodes
3. Constantes et Classes
“[...] systems design needs to emphasize human, rather than computer, needs.”Yukihiro Matsumoto
STRANGER_RUBY = "🐙"
$stranger_ruby = "🚀"
@@stranger_ruby = "🦊"
@stranger_ruby = "🐳"
stranger_ruby = "🦄"
def stranger_ruby
"🔥"
end
stranger_ruby = "🚀"
def stranger_ruby
"🔥"
end
p stranger_ruby
define_method %w[stranger ruby].join('_') do
"🔥"
end
p stranger_ruby
Les constantes sont variables.
StrangerRuby = "C'est le "
StrangerRuby << "🔥"
p StrangerRuby #=> "C'est le 🔥"
Les classes sont des constantes.
class Integer
def is_one?
self == 1
end
end
class Array
def second
self[1]
end
end