Skip to content

Instantly share code, notes, and snippets.

@8th-Light-Blog
Created June 29, 2011 15:15
Show Gist options
  • Save 8th-Light-Blog/1054054 to your computer and use it in GitHub Desktop.
Save 8th-Light-Blog/1054054 to your computer and use it in GitHub Desktop.
Blog Title: Rolemodel Recap Day 2
Author: Doug Bradbury
Date: January 21st, 2011
require 'ostruct'
record = OpenStruct.new
record.name = "John Smith"
record.age = 70
record.pension = 300
puts record.name # -> "John Smith"
puts record.address # -> nil
hash = { "country" => "Australia", :population => 20_000_000 }
data = OpenStruct.new(hash)
some_array.collect { |item| item.is_something? }
some_array.collect(&:is_something?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment