Skip to content

Instantly share code, notes, and snippets.

@selman
Created July 16, 2010 13:25
Show Gist options
  • Save selman/478356 to your computer and use it in GitHub Desktop.
Save selman/478356 to your computer and use it in GitHub Desktop.
require 'yaml'
s = "a string"
a = %w(a array)
puts "Before setting instance variable:\n#{s.to_yaml}\n#{a.to_yaml}\n"
s.instance_variable_set(:@test, 'test')
a.instance_variable_set(:@test, 'test')
puts "After setting instance variable:\n#{s.to_yaml}\n#{a.to_yaml}\n"
# Before setting instance variable:
# --- a string
# ---
# - a
# - array
# After setting instance variable:
# --- !str
# str: a string
# :@test: test
# ---
# - a
# - array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment