new files

This commit is contained in:
Ingy döt Net 2013-04-10 12:38:42 -07:00
parent 3af7344581
commit 86c034bb8b
1364 changed files with 21352 additions and 0 deletions

View file

@ -0,0 +1,45 @@
# string creation
x = "hello world"
# string destruction
x = nil
# string assignment with a null byte
x = "a\0b"
x.length # ==> 3
# string comparison
if x == "hello"
puts equal
else
puts "not equal"
end
y = 'bc'
if x < y
puts "#{x} is lexicographically less than #{y}"
end
# string cloning
xx = x.dup
x == xx # true, same length and content
x.equal?(xx) # false, different objects
# check if empty
if x.empty?
puts "is empty"
end
# append a byte
x << "\07"
# substring
xx = x[0..-2]
# replace bytes
y = "hello world".tr("l", "L")
# join strings
a = "hel"
b = "lo w"
c = "orld"
d = a + b + c