I’m specifically using OS X Terminal.app for command line stuff, but this question may also apply to other command line tools.
Say I want to run this block of ruby code from the command line:
Cats.each do |cat|
cat.name = 'Mommy'
cat.kittens each do |kitten|
kitten.color = "Brown"
end
end
Right now if I copy/paste that it just gets broken up and doesn’t execute.
Please note that Terminal.app is not itself a Ruby interpreter. You’ll want to fire up
irbto get an interactive Ruby console:There are other tricks you can use to run
irbin the context of a particular script.