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.

begin rescue/ensure

  • Thread starter bedi nik bzez emak
  • Start date

poccil

Sponsor

One possible use for a "begin ... end" statement is for implementing the "do ... while" loop in C, where a loop is
guaranteed to run at least once.

Code:
x=0
begin
  x+=1
end while x<5

Other than that, a "begin ... end" statement standing alone is probably useless.
 

poccil

Sponsor

In the code for Font_Test that's a rather poor use of classes, and the "begin ... end" statement certainly wasn't used to create a loop, as I mentioned above.  The following would look better:

Code:
module Font_Test
    Font.default_name = "Rod"
    Font.default_size = 15
end

But even with this, a module is useless without methods in any case.
 

khmp

Sponsor

Don't say it's a poor fix if it works a 100% of the time with no bugs. :) Thanks poccil I didn't know "begin" could be used in conjuction with a 'while'. I should have known Ruby had more ways of looping.
 
"Thanks poccil I didn't know "begin" could be used in conjuction with a 'while'. I should have known Ruby had more ways of looping."

eh, maybe if you take a look at Main you'd notice that it includes a begin and a while already...
edit:
mmm on the same level, interesting...
 

khmp

Sponsor

Rofl don't make fun. That while is within the loop. The while loop he created was by placing the while on the same line as the end. Kind of like a do while loop in C.
 

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