mercredi 2 décembre 2015

Is it possible to use `retry` keyword inline with `if`?

I have to surround everything with begin-rescue-end block. I've written code that looks like:

begin
  bet = Dialogs.enter_your_bet
  approx.calculate_average_profit(bet)
  approx.print_profits_table
  retry if Dialogs.play_again?
rescue;retry
end

The line retry if Dialogs.play_again? caused the following error:

./main:14: Invalid retry
./main: compile error (SyntaxError)

Is it possible to make this kind of inline retry to work with if clause without regular if-end multiline approach?

Aucun commentaire:

Enregistrer un commentaire