#!/usr/local/bin/ruby

x = "a string\n"
puts "x = #{x}"

y = x.chomp!
puts "after chomping y = #{y}"
y = x.chomp!
puts "after chomping y = #{y}"

z = "another string\n"

z.chop!
puts "after choping z = #{z}"
z.chop!
puts "after choping z = #{z}"

m = "a string"
n = " with more string"
m << n
printf("m is %s,        n is %s\n",m,n)

f = "Roger "
l = "Eggen"
# not sure about >>
# name = f >> l
f << l
printf("Result of concatentation is %s\n\n",f)
Published in: Ruby
Download

Related snippets