Don't name a method "next"!
-
Here is
bug_splat.rb, which does as its name suggests when you try to load it.def bug_splat() next() endEdit: typing
next()into the Ruby Console gets a Bug Splat. -
Hey cool, it "works" the same if you just type it in the Ruby Console.
nextdoes not bugsplat,next()does. -
nextis a Ruby reserved keyword used to control loop iteration. -
nextis also a method meaning "give me the next value."1.next ==> 2 "a".next ==> "b" -
-
Try it from the rerula - non SU ruby command line editor. I doubt it will give a bugsplat
Maybe it just returns an error, or critical error or something. -
@jim said:
nextis also a method meaning "give me the next value."1.next ==> 2 "a".next ==> "b"Good point. But that leads to the question; is "reserved" really reserved in Ruby?
Sonextcan be class method, but not a root method? -
let's see (Mac, ruby 1.8.6, command line)
irb >> next() LocalJumpError; unexpected next from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/workspace.rb;81;in `evaluate' Maybe IRB bug!! ruby -e "next()" -e;1; unexpected next (LocalJumpError)so it is more a ruby problem than a SU. but why the exception is not trapped by SU ?
-
Windows7, Ruby 1.8.0 - Console Session (IRB)
C;\Users\Thomas>irb irb(main);001;0> next() LocalJumpError; unexpected next from C;/Ruby/lib/ruby/1.8/irb/workspace.rb;81;in `evaluate' from C;/Ruby/lib/ruby/1.8/irb/context.rb;219;in `evaluate' from C;/Ruby/lib/ruby/1.8/irb.rb;150;in `eval_input' from C;/Ruby/lib/ruby/1.8/irb.rb;263;in `signal_status' from C;/Ruby/lib/ruby/1.8/irb.rb;147;in `eval_input' from C;/Ruby/lib/ruby/1.8/irb/ruby-lex.rb;244;in `each_top_level_statement' from C;/Ruby/lib/ruby/1.8/irb/ruby-lex.rb;230;in `loop' from C;/Ruby/lib/ruby/1.8/irb/ruby-lex.rb;230;in `each_top_level_statement' from C;/Ruby/lib/ruby/1.8/irb/ruby-lex.rb;229;in `catch' from C;/Ruby/lib/ruby/1.8/irb/ruby-lex.rb;229;in `each_top_level_statement' from C;/Ruby/lib/ruby/1.8/irb.rb;146;in `eval_input' from C;/Ruby/lib/ruby/1.8/irb.rb;70;in `start' from C;/Ruby/lib/ruby/1.8/irb.rb;69;in `catch' from C;/Ruby/lib/ruby/1.8/irb.rb;69;in `start' from C;/Ruby/bin/irb;13 Maybe IRB bug!! irb(main);002;0> exit C;\Users\Thomas>
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register LoginAdvertisement