Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Wrapping code

topman

Member

I have looked over various ruby guides and can not find the answer, I also have no code to show for my question, I'm trying to find out before I hit a brick wall.

I don't like code that writes past the side bar, so how would I wrap code? I think wrap is the right word but I'm not too sure, if it's not then what I mean is how do I make a long line run on 2-3 lines instead so it doesn't go past the side bar?
 

khmp

Sponsor

Just move it to the next line. The following code for example:

Code:
really_long_variable_name = 10
this_is_unrealistically_named = 5
this_will_be_the_answer = 0

this_will_be_the_answer = 
really_long_variable_name / this_is_unrealistically_named + 
this_is_unrealistically_named

Or use extra parenthesis to make code like that a little easier to interpret.

Code:
really_long_variable_name = 10
this_is_unrealistically_named = 5
this_will_be_the_answer = 0

this_will_be_the_answer = 
((really_long_variable_name / this_is_unrealistically_named) + 
this_is_unrealistically_named)

With the assignment operator it'll continue to read until it encounters another operation or at least it appears to do that.
 
I dunno if this interprets into RGSS, but in Ruby in general, if you end with an operation it'll carry on as if it's just one line.

I.e.

@variablename = 1 +
2

Will do the same as @variablename = 1 + 2

Dunno if that helps at all.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top