In this example we can see how to pass a block to a Struck for a default value.

Course = :title, :major, :location do
  def initialize(*)
    self.location ||= 'UCLA'

course ="Machine Learning", 'Comp Sci')
=> # 

course ="Machine Learning", 'Comp Sci', "UCSD")
=> #


    • Fred February 23, 2014
    • Reply

    Small typo, self.location should be

    • Brett February 23, 2014
    • Reply

    Thanks, switched university for location in the creation of the struct.

Leave a Reply

Screen Shot 2013-12-08 at 9.49.35 PM

I have helped a dozen companies build and optimize their engineering teams to deliver great products.

Let’s work together and I can align your business needs with your technology initiatives.