DEV Community

Discussion on: Picking up Ruby Fast, as a Python Dev pt II

Collapse
 
topofocus profile image
Hartmut B. • Edited

Just a reminder

def throw( amount , toys="toys", for: "the dog")
   name = for
  ["ball", "frisbee", "rock", "another ball", "cat"].each do  | toy |
        puts "threw #{toy} #{amount} times for #{name.capitalize}"
    end
end

# then these calls are valid
throw 4
throw 4, :toys 
throw 3, :toys, for:  'my dog'
throw 3, for: 'any dog'
Enter fullscreen mode Exit fullscreen mode

is more rubish

Collapse
 
vickilanger profile image
Vicki Langer

Interesting. Like I said in my post, Ruby is brand new to me. Thanks for the refactor.

In def throw( amount , toys="toys, for: "the dog"), there are only 3 quotes. I there a reason they aren't in pairs? I'm not sure what this part means right now

Collapse
 
topofocus profile image
Hartmut B. • Edited

Just edited my comment to correct the mistake.
I always try to design interfaces in a human stile. If you are able to express a method-call like a short sentence, no comments are needed.

Thread Thread
 
vickilanger profile image
Vicki Langer

Okay, I thought maybe it was a typo, but with Ruby being new to me I wasn't sure if it was just something new to me.

Thanks for helping me out and not throwing me some foo bar example