Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,9 @@
original = "hello"
reference = original # copies reference
copy1 = original.dup # instance of original.class
copy2 = String.new(original) # instance of String
original << " world!" # append
p reference #=> "hello world!"
p copy1 #=> "hello"
p copy2 #=> "hello"

View file

@ -0,0 +1,7 @@
original = "hello".freeze # prevents further modifications
copy1 = original.dup # copies contents (without status)
copy2 = original.clone # copies contents (with status)
p copy1.frozen? #=> false
p copy1 << " world!" #=> "hello world!"
p copy2.frozen? #=> true
p copy2 << " world!" #=> can't modify frozen String (RuntimeError)

View file

@ -1,4 +0,0 @@
original = "hello"
reference = original
copy1 = original.dup # instance of original.class
copy2 = String.new(original) # instance of String