Learning ruby, oreilly/Samples/dice.rb
# virtual roll of a pair of dice
virtual roll of a pair of dice
virtual roll of a pair of dice
def roll
    r_1 = rand(6); r_2 = rand(6)
    r1 = r_1>0?r_1:1; r2 = r_2>0?r_2:6
    total = r1+r2
    printf( "You rolled %d and %d (%d).\n", r1, r2, total )
    total
  end
def roll r_1 = rand ( 6 ) ; r_2 = rand ( 6 ) r1 = r_1 > 0 ? r_1 : 1 ; r2 = r_2 > 0 ? r_2 : 6 total = r1 + r2 printf ( "You rolled %d and %d (%d).\n" , r1 , r2 , total ) total end
virtual roll of a pair of dice
virtual roll of a pair of dice