N
Neville Franks
Hi, Can someone please shed some light on the following code:
---
def test_listen
s = nil
log = Object.new
class << log; self end.__send__define_method, :to_int) {
s.close
2
}
inet_stream do |s|
assert_raise(IOError) {
s.listen(log)
}
end
end
---
In particular the "class" statement and "self
end.__send__define_method, :to_int)"
Is this actually a class and where is its "end"?
I didn't know you can have a class inside a method. So I'm confused here
as well.
This code is messing up the Ruby parser I'm working on in my IDE.
---
def test_listen
s = nil
log = Object.new
class << log; self end.__send__define_method, :to_int) {
s.close
2
}
inet_stream do |s|
assert_raise(IOError) {
s.listen(log)
}
end
end
---
In particular the "class" statement and "self
end.__send__define_method, :to_int)"
Is this actually a class and where is its "end"?
I didn't know you can have a class inside a method. So I'm confused here
as well.
This code is messing up the Ruby parser I'm working on in my IDE.