Skip to content

Instantly share code, notes, and snippets.

@fredjean
Created December 28, 2009 18:13
Show Gist options
  • Save fredjean/264822 to your computer and use it in GitHub Desktop.
Save fredjean/264822 to your computer and use it in GitHub Desktop.
>> x = java.lang.reflect.Array.newInstance(java.lang.Class.forName("java.lang.String"), 0)
=> #<#<Class:01x4657104d>:0x7def534e @java_object=#<Java::JavaArray:0x6b466679>>
>> x.blank?
=> false
>> x.length
=> 0
>> x[0]
ArgumentError: index out of bounds for java array (0 for length 0)
from (irb):5:in `[]'
from (irb):5
>> x = java.lang.reflect.Array.newInstance(java.lang.Class.forName("java.lang.String"), 1)
=> #<#<Class:01x4657104d>:0x3a8c5214 @java_object=#<Java::JavaArray:0x5260bd13>>
>> x.blank?
=> false
>> x.length
=> 1
>> x[0]
=> nil
>> puts JRUBY_VERSION
1.3.1
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment