Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.86 KB | None | 0 0
  1. BEGIN {
  2. puts "Ruby Init.."
  3. }
  4.  
  5. END {
  6. puts "Ruby End..."
  7. }
  8.  
  9. class Person
  10. #makes the variable @name open to others
  11. attr_accessor :names
  12.  
  13. def initialize(name)
  14.  @names = name
  15. end
  16.  
  17. def say_hi
  18.  puts "Hello #{@names}!"
  19. end
  20.  
  21. def say_bye
  22.  puts "Going so soon, #{@names}?"
  23. end
  24.  
  25. end
  26.  
  27.  
  28. test = <<EOF
  29.  Hello there, this is a multiline string variable in ruby!
  30.  So far, I am absolutely LOVING the ruby language :D!
  31. It's Cool!
  32. EOF
  33.  
  34. puts test
  35. g = Person.new("umby24")
  36. g.say_hi
  37. g.say_bye
  38. g.names = "umby"
  39. g.say_hi
  40. g.say_bye
  41.  
  42. (10..15).each do |n|
  43. puts n
  44. end
  45.  
  46. =begin
  47. Output of this program is:
  48.  
  49. Ruby init..
  50.  Hello there, this is a multiline string variable in ruby!
  51.  So far, I am absolutely LOVING the ruby language :D!
  52. It's Cool!
  53. Hello umby24!
  54. Going so soon, umby24?
  55. Hello umby!
  56. Going so soon, umby?
  57. 10
  58. 11
  59. 12
  60. 13
  61. 14
  62. 15
  63. Ruby End...
  64. =end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement