Skip to content

Instantly share code, notes, and snippets.

@mehdi-farsi
Created August 22, 2018 12:53
Show Gist options
  • Save mehdi-farsi/806d695f12255347a542c8389fb4c4e3 to your computer and use it in GitHub Desktop.
Save mehdi-farsi/806d695f12255347a542c8389fb4c4e3 to your computer and use it in GitHub Desktop.
require 'ostruct'
computer = OpenStruct.new(ram: '4GB')
computer.class # => OpenStruct
computer.methods(false) # => []
computer[:ram] # => "4GB"
computer.methods(false) # => []
computer.ram # => "4GB"
computer.methods(false) # => [:ram, :ram=]
computer[:screens] = 2 # => 2
computer.methods(false) # => [:ram, :ram=, :screen, :screen=]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment