From: Ben Bleything Date: 2007-08-09T07:54:22+09:00 Subject: Re: from irb to .rb? and general question On Thu, Aug 09, 2007, Simon Schuster wrote: > say I've been mucking about in irb and want to save some of/all > previous steps into file.rb, is there a way to do this? My irb history hack can do this: http://blog.bleything.net/pages/irb_history history_write (aliased to hw) takes a filename and a collection of lines and writes those lines to the file. Alternately, if you've enabled saving history across sessions, you can just extract the lines you want from the file it uses for this. Try ~/.irb.history or ~/.irb_history, though I'm sure there are other variants. > also, I've been going through (mostly reading) some tutorials, and am > just slightly confused on how it works when you call up something, a > class or a method definition, and then recall it later.... it doesn't > overwrite what's previously there, just add to it? though in some > cases it seems to overwrite what's already there... but this clearly > isn't the case if I'm making methods in the Array class, for example. Sorta! When you re-open a class, you're adding. If you "re-open" a method, you're overriding. str = "string" str.reverse => "gnirts" class String # additive def upper_case_it self.upcase end # replace...ative def reverse return "reversed!" end end str.upper_case_it => STRING str.reverse => "reversed!" Ben