RosettaCodeData/Task/Substring-Top-and-tail/Ruby/substring-top-and-tail.rb

6 lines
254 B
Ruby
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
puts "knight"[1..-1] # strip first character
puts "socks"[0..-2] # strip last character
puts "socks".chop # alternate way to strip last character
puts "brooms"[1..-2] # strip both first and last characters
2015-02-20 00:35:01 -05:00
puts "与今令"[1..-2] # => 今