Created
March 7, 2016 16:04
-
-
Save theHamdiz/45c22ab8adfa43be9b93 to your computer and use it in GitHub Desktop.
very basic example of object serialization in #ruby...
This file contains hidden or 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
| 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