On Apr 9, 2006, at 2:41 PM, Simon Strandgaard wrote:

> On 4/9/06, Joern Dinkla <joern / dinkla.net> wrote:
> [snip]
>> I programmed it to learn Ruby and to improve my coding skills,  
>> because i
>> have less than 2,5 weeks of experience with Ruby. I bought the
> [snip]
>
>
> You are doing good.
>
> sometimes you use parentesis and other times you don't.
> def test()     is the same as    def test
> if(cond)     is the same as    if cond
> .length()    is the same as    .length
>
>
>
>    File.open(filename) do | file |
>      file.each_line() do |line|
>
> is the same as
>
>    IO.readlines(filename).each do |line|

Let's use foreach() there, so we don't slurp a file only to process  
it line by line:

File.foreach(filename) do |line| ... end

> def initialize(mc = nil)
>    if mc.nil?
>      @mc = MarkovChain.new()
>    else
>      @mc = mc
>    end
>  end
>
> is the same as
>
> def initialize(mc = nil)
>   @mc = mc || MarkovChain.new
> end

Why not just set the default correctly?

def initialize( mc = MarkovChain.new )
   @mc = mc
end

James Edward Gray II