Skip to content

Instantly share code, notes, and snippets.

@shime
Created January 14, 2012 00:14
Show Gist options
  • Save shime/1609496 to your computer and use it in GitHub Desktop.
Save shime/1609496 to your computer and use it in GitHub Desktop.
instance_eval explanation
val = "pizdarija"
val.randomize
val.instance_eval do
def randomize
split(//).to_a.shuffle.join
end
end
val.randomize
val2 = "faraon"
val2.randomize
String.class_eval do
def randomize
puts "defined with class eval"
split(//).to_a.shuffle.join
end
end
"drek".randomize
val.randomize
@shime
Copy link
Author

shime commented Jan 14, 2012

Bacat će ti errore na linijama 3 i 17, zbriši ih. To je čisto tek toliko da vidiš.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment