Skip to content

Instantly share code, notes, and snippets.

@theHamdiz
Created March 7, 2016 16:04
Show Gist options
  • Select an option

  • Save theHamdiz/45c22ab8adfa43be9b93 to your computer and use it in GitHub Desktop.

Select an option

Save theHamdiz/45c22ab8adfa43be9b93 to your computer and use it in GitHub Desktop.
very basic example of object serialization in #ruby...
class GameCharacter
def initialize(name, type, weapons)
@name = name
@type = type
@weapons = weapons
end
attr_accessor :name, :type, :weapons
end
gc = GameCharacter.new('Youssif', 'Magician', ['Invisibility', 'Spells'])
File.write('game', Marshal.dump(gc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment