small medium large xlarge

05 Oct 2017, 14:35
ken mcfadden (4 posts)

Chapter 5 Unit specs:

class API < Sinatra::Base def initialize(ledger:) (what is ledger: ? its not the syntax for a symbol..its like a half hash or something) @ledger = ledger super() end end

05 Oct 2017, 14:55
ken mcfadden (4 posts)

Never mind found it…keyword argument…just have not used yet in anything.

def foo(bar:) puts bar end

foo # => ArgumentError: missing keyword: bar foo(bar: ‘baz’) # => ‘baz’

10 Oct 2017, 17:00
Myron Marston (13 posts)

Yep! Keyword arguments were a new feature in Ruby 2.0. Ruby 2.1 extended the keyword arguments feature to support required keyword arguments, which is what we’re using there.

You must be logged in to comment