Skip to content

Instantly share code, notes, and snippets.

@r00k
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r00k/e748e2483b83a41367ac to your computer and use it in GitHub Desktop.
Save r00k/e748e2483b83a41367ac to your computer and use it in GitHub Desktop.
Ruby Quiz Question 3

Answer to Question 2:

The syntax shown is for required keyword arguments.

Here's an example:

def foo(bar:)
  puts bar
end

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

Guess which robotically-themed company wrote a handy post about Ruby 2's Keyword Arguments?

Can you name this "Gang of Four" design pattern?

class TrailWithProgress < SimpleDelegator
  def initialize(trail)
    super(trail)
    @trail = trail
  end

  def incomplete?
    unstarted? || in_progress?
  end

  private

  def unstarted?
    # ...
  end

  def in_progress?
    # ...
  end
end

To the answer, and step on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment