Em 06-07-2012 10:48, Maksym Parkachov escreveu:
Hi developers,
I'm trying version 1.7 preview, which works great and fast btw., and
becoming a lot of warning concerning singleton on non-persistent Java
type.
The pattern, I'm using:
require 'java'
java_import java.util.ArrayList
class ArrayList
def psize
puts size
end
end
list = ArrayList.new
list.instance_exec do
psize
add 10
psize
end
While, currently it works, it generates warning:
jruby ss.rb
ss.rb:1 warning: singleton on non-persistent Java type
Java::JavaUtil::ArrayList (http://wiki.jruby.org/Persistence)
0
1
I understand, that singleton class will be generated, if I change
class definition with instance_exec, but executing methods should not
create singleton ? Or should it ?
While, of course, I could use:
list.psize
list.add 10
list.psize
i wanted to avoid it, because I have a lot of code which should be
executed like this.
If the only reason is to avoid lots of typing, you could do something like:
myLongListNameIDontWantToRepeat.tap do |l|
l.psize
l.add 10
l.psize
...
end
Does it help a bit?
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email