-
-
Save 8th-Light-Blog/1054054 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blog Title: Rolemodel Recap Day 2 | |
Author: Doug Bradbury | |
Date: January 21st, 2011 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
some_array.collect { |item| item.is_something? } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
some_array.collect(&:is_something?) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment