Skip to content

Instantly share code, notes, and snippets.

@davidpatters0n
Created March 21, 2015 15:10
Show Gist options
  • Save davidpatters0n/b7d3090763f183637659 to your computer and use it in GitHub Desktop.
Save davidpatters0n/b7d3090763f183637659 to your computer and use it in GitHub Desktop.
def eval_string(klass, attrib)
s = <<EOS
class #{klass}
def #{attrib}
@#{attrib}
end
def #{attrib}=(value)
@#{attrib} = value
end
end
EOS
return s
end
eval(eval_string(String, "ahmet"))
x = String.new
x.ahmet = "abdi"
puts x.ahmet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment