From: Simon Schuster Date: 2007-09-07T12:50:15+09:00 Subject: Re: help me condence my code? putting it into phrase-test.rb and running it that way I get: ph-test.rb:3: undefined method `delete_at' for nil:NilClass (NoMethodError) from ph-test.rb:10:in `each_with_index' from ph-test.rb:1:in `each' from ph-test.rb:1:in `each_with_index' from ph-test.rb:1 and relatedly, going through step by step I get: 023:0> end.delete_at(-1) SyntaxError: compile error (irb):23: syntax error, unexpected kEND end.delete_at(-1) I've never seen tacking things onto end before! is this possible? > f = IO.readlines("phrases_no_extra.txt").each_with_index do |x, y| > if x.chop!.size.eql?(0) > f.delete_at(y) > end > if x.include?("]") or x.include?("[") > f.delete_at(y) > end > end.delete_at(-1) > puts f[rand(f.size)] > > > let me know how it goes! > > > ~Jeremy > -- > Posted via http://www.ruby-forum.com/. > >