sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Don't name a method "next"!

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 5 Posters 596 Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      MartinRinehart
      last edited by Gábor

      Here is bug_splat.rb, which does as its name suggests when you try to load it.

      
      def bug_splat()
          next()
      end
      
      

      Edit: typing next() into the Ruby Console gets a Bug Splat.

      Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

      1 Reply Last reply Reply Quote 0
      • J Offline
        Jim
        last edited by

        Hey cool, it "works" the same if you just type it in the Ruby Console.

        next does not bugsplat, next() does.

        Hi

        1 Reply Last reply Reply Quote 0
        • thomthomT Offline
          thomthom
          last edited by

          next is a Ruby reserved keyword used to control loop iteration.

          Thomas Thomassen — SketchUp Monkey & Coding addict
          List of my plugins and link to the CookieWare fund

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jim
            last edited by

            next is also a method meaning "give me the next value."

            1.next ==> 2 "a".next ==> "b"

            Hi

            1 Reply Last reply Reply Quote 0
            • M Offline
              MartinRinehart
              last edited by

              @thomthom said:

              next is a Ruby reserved keyword used to control loop iteration.

              Some languages handle the misuse of a reserved word with a bit more grace.

              Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

              1 Reply Last reply Reply Quote 0
              • Chris FullmerC Offline
                Chris Fullmer
                last edited by

                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.

                Lately you've been tan, suspicious for the winter.
                All my Plugins I've written

                1 Reply Last reply Reply Quote 0
                • thomthomT Offline
                  thomthom
                  last edited by

                  @jim said:

                  next is 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?
                  So next can be class method, but not a root method?

                  Thomas Thomassen — SketchUp Monkey & Coding addict
                  List of my plugins and link to the CookieWare fund

                  1 Reply Last reply Reply Quote 0
                  • tbdT Offline
                    tbd
                    last edited by

                    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 ?

                    SketchUp Ruby Consultant | Podium 1.x developer
                    http://plugins.ro

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      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>
                      
                      

                      Thomas Thomassen — SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      • First post
                        Last post
                      Buy SketchPlus
                      Buy SUbD
                      Buy WrapR
                      Buy eBook
                      Buy Modelur
                      Buy Vertex Tools
                      Buy SketchCuisine
                      Buy FormFonts

                      Advertisement