Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array#append does not exist in JRuby? #269

Closed
azumakuniyuki opened this issue Mar 6, 2024 · 9 comments
Closed

Array#append does not exist in JRuby? #269

azumakuniyuki opened this issue Mar 6, 2024 · 9 comments
Labels
java Issue related to JRuby

Comments

@azumakuniyuki
Copy link
Member

NoMethodError: undefined method `append' for []:Array
@azumakuniyuki azumakuniyuki added the java Issue related to JRuby label Mar 6, 2024
@hiroyuki-sato
Copy link
Contributor

JRuby itself supports append method.

java -jar jruby-complete-9.4.6.0.jar -S irb
irb(main):001:0> a = []
=> []
irb(main):002:0> a.append("a")
=> ["a"]

@azumakuniyuki
Copy link
Member Author

@hiroyuki-sato Thank you for checking. However, at least JRuby 9.1 does not have Array#append as follows:

jruby 9.1.17.0 (2.3.3) 2018-04-20 d8b1ff9 Java HotSpot(TM) 64-Bit Server VM 11.0.5+10-LTS on 11.0.5+10-LTS +jit [darwin-x86_64]

irb(main):001:0> v = []
=> []
irb(main):002:0> v.append("neko")
NoMethodError: undefined method `append' for []:Array
	from (irb):2:in `<eval>'
	from org/jruby/RubyKernel.java:995:in `eval'
	from org/jruby/RubyKernel.java:1316:in `loop'
	from org/jruby/RubyKernel.java:1138:in `catch'
	from org/jruby/RubyKernel.java:1138:in `catch'
	from /usr/local/jr/bin/irb:13:in `<main>'

@hiroyuki-sato
Copy link
Contributor

hiroyuki-sato commented Mar 6, 2024

@azumakuniyuki

JRuby 9.1.x.x is compatible with Ruby 2.3. Array#append was introduced in MRI 2.5
https://docs.ruby-lang.org/en/3.2/NEWS/NEWS-2_5_0.html
https://bugs.ruby-lang.org/issues/12746

You can use push instead.

java -jar ~/.embulk/jars/jruby-complete-9.1.15.0.jar -S irb --readline
irb(main):001:0> JRUBY_VERSION
=> "9.1.15.0"
irb(main):002:0> RUBY_VERSION
=> "2.3.3"
irb(main):003:0> a = []
=> []
irb(main):004:0> a.push("a")
=> ["a"]

@azumakuniyuki
Copy link
Member Author

@hiroyuki-sato Thank you for the announce of push method. I've decided that Sisimai 5 requires JRuby 9.2 or later because Sisimai 5 requires Ruby 2.4 or later.

irb(main):004:0> JRUBY_VERSION
=> "9.2.21.0"
irb(main):005:0> RUBY_VERSION
=> "2.5.8"
irb(main):006:0> p=[]; p.append("neko")
=> ["neko"]

@hiroyuki-sato
Copy link
Contributor

I've decided that Sisimai 5 requires JRuby 9.2 or later because Sisimai 5 requires Ruby 2.4 or later.

Off topic. It seems that append was introduced in Ruby 2.5. Sisimai supports Ruby 2.4? (Maybe there is no Array#append method in Ruby 2.4)

@azumakuniyuki
Copy link
Member Author

I thought I would use Array#append because I planned to use Ruby 2.6 or later in the early development of Sisimai 5, but after many years, I forgot everything and wrote 2.4...
Therefore, I will try to replace Array#append with Array#push today.

@hiroyuki-sato
Copy link
Contributor

JFYI: And Ruby 2.7 already EOL
https://www.ruby-lang.org/ja/downloads/branches/

@azumakuniyuki
Copy link
Member Author

!

@azumakuniyuki
Copy link
Member Author

This issue resolved at v5.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java Issue related to JRuby
Projects
None yet
Development

No branches or pull requests

2 participants