T
Trans
Have a look at this. Note that I'm not bothering to implement the
#shuffle method as it is not the point --it's just an foo example.
module Kernel
def express(name)
extend self.class.const_get(name.to_s.capitalize)
end
end
class Array
module Random
def shuffle
[] # ...
end
def shuffle!
replace(shuffle)
end
# ...
end
end
a = [1,2,3]
a.shuffle #=> NoMethodError
a.express
Random)
a.shuffle #=> []
T.
#shuffle method as it is not the point --it's just an foo example.
module Kernel
def express(name)
extend self.class.const_get(name.to_s.capitalize)
end
end
class Array
module Random
def shuffle
[] # ...
end
def shuffle!
replace(shuffle)
end
# ...
end
end
a = [1,2,3]
a.shuffle #=> NoMethodError
a.express
a.shuffle #=> []
T.