R
Richard
Hi All,
The program below ends with eval(...) producing an error message, as
shown in the comments at the end of the code. How can I direct the
offending output to a "bit bucket"?
Thanks in Advance,
Richard
class MyClass
def initialize(n)
@number = n
end
def getBinding
binding()
end
end
def show(a)
a.each do |m|
puts "\t" + m.inspect
end
end
obj1 = MyClass.new 19
bind1 = obj1.getBinding
obj2 = MyClass.new 84
bind2 = obj2.getBinding
puts "number for obj1 = " + eval('@number', bind1).to_s
puts "number for obj2 = " + eval('@number', bind2).to_s
puts "# of methods: " + eval(methods.length.to_s, bind1).to_s
puts "Methods: "
dummy = eval(show(methods), bind1)
puts "That's all folks!"
=begin
# Result:
number for obj1 = 19
number for obj2 = 84
# of methods: 46
Methods:
[snip]
TestBinding.rb:28:in `eval': cannot convert Array into String
(TypeError)
from TestBinding.rb:28
=end
The program below ends with eval(...) producing an error message, as
shown in the comments at the end of the code. How can I direct the
offending output to a "bit bucket"?
Thanks in Advance,
Richard
class MyClass
def initialize(n)
@number = n
end
def getBinding
binding()
end
end
def show(a)
a.each do |m|
puts "\t" + m.inspect
end
end
obj1 = MyClass.new 19
bind1 = obj1.getBinding
obj2 = MyClass.new 84
bind2 = obj2.getBinding
puts "number for obj1 = " + eval('@number', bind1).to_s
puts "number for obj2 = " + eval('@number', bind2).to_s
puts "# of methods: " + eval(methods.length.to_s, bind1).to_s
puts "Methods: "
dummy = eval(show(methods), bind1)
puts "That's all folks!"
=begin
# Result:
number for obj1 = 19
number for obj2 = 84
# of methods: 46
Methods:
[snip]
TestBinding.rb:28:in `eval': cannot convert Array into String
(TypeError)
from TestBinding.rb:28
=end