Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There are no 'keyword arguments', however Ruby does provide syntax sugar for options hashes.

For example, this:

    my_method(1, 2, three: 3, four: 4)
Is the same as this:

    my_method(1, 2, { three: 3, four: 4 })
Which can be picked up by the method like this:

    def my_method(one, two, opts)
      three = opts[:three]
      four = opts[:four]
      puts one, two, three, four
    end


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: