0

I'm trying to port a ruby code base to mruby. In ruby (MRI), I can do (and unfortunately, the person who wrote it did)

begin
  statement
end until condition

which executes statement once until and then until condition becomes positive. In mruby, however, the behavior is different, and the condition is evaluated before the first run, so this is equivalent to a while statement. What is the least intrusive alternative to this construct in mruby?

On a side note, is it possible to patch mruby so that this (and other) behavior becomes similar? I mean is there an existing set of patches that do this?

pulsejet
  • 1,101
  • 13
  • 27
  • MRuby closely follows the ISO Ruby Language Specification. In general, as soon as you write code that depends on behavior that is outside the ISO specification, you are on your own. – Jörg W Mittag May 04 '18 at 20:50
  • @JörgWMittag fully agree. Unfortunately, people do write such code and others are forced to deal with it :( – pulsejet May 04 '18 at 20:58

1 Answers1

3

loop with break would probably work:

loop do
  statement
  break if condition
end
Stefan
  • 109,145
  • 14
  • 143
  • 218