Author Topic: I'm learning Ruby  (Read 1277 times)

TI-84 programming is master.

yes. it wil happen soun. its inevitable. embrace the operating room where your sister will soon be.
Soun

I made a script which randomizes a number and lets you guess what it is.
It will either tell you your guess is too low or too high depending on what you guessed.
You get unlimited guesses.

To run it, you'll need Aptana RadRails 2.0.5 or a similar program (which supports ruby of course) to run it.

Download

Or you could just copy this:
Code: [Select]
puts 'I\'m thinking of a number between 0 and 100, try to figure it out.'
num=(rand(100)) +1
input = ''

while input.to_i != num
     input=gets.chomp
  if input.to_i < num
    puts 'That\'s too low.'
  elsif input.to_i > num
    puts 'That\'s too high.'
    end
end

puts 'You got the number!'


If someone knows how to convert ruby files to console programs, please tell me.

How the forget do I make a | on a mac

If someone knows how to convert ruby files to console programs, please tell me.
Begin the file with "#!ruby" and set the executable permission with "chmod +x myscript.rb". Note that everyone wanting to use it will have to do the second bit.

How the forget do I make a | on a mac
Alt+Shift+7.

now learn emerald and sapphire