/test/string.rb

http://github.com/feyeleanor/RubyGoLightly · Ruby · 45 lines · 18 code · 10 blank · 17 comment · 0 complexity · 07b2ffa1b03ad4b2ac5366f9adedaba9 MD5 · raw file

  1. puts "ohaie"
  2. # => ohaie
  3. puts "ohaie".size
  4. # => 5
  5. puts "ohaie".class.name
  6. # => String
  7. puts "oh" + "aie"
  8. # => ohaie
  9. puts "oh\naie"
  10. # => oh
  11. # => aie
  12. puts "\"oh\" \\ \\n"
  13. # => "oh" \ \n
  14. puts '\''
  15. # => '
  16. puts "
  17. hey
  18. "
  19. # =>
  20. # => hey
  21. # =>
  22. a = "xxx"
  23. a.replace "aaa"
  24. puts a
  25. # => aaa
  26. puts "a" <=> "b"
  27. # => -1
  28. puts "a" <=> "a"
  29. # => 0
  30. puts "ohaie".substring(0,2)
  31. # => oh
  32. puts "ohaie".substring(2,3)
  33. # => aie
  34. puts "ohaie".substring(2,4)
  35. # =>