Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BEGIN {
- puts "Ruby Init.."
- }
- END {
- puts "Ruby End..."
- }
- class Person
- #makes the variable @name open to others
- attr_accessor :names
- def initialize(name)
- @names = name
- end
- def say_hi
- puts "Hello #{@names}!"
- end
- def say_bye
- puts "Going so soon, #{@names}?"
- end
- end
- test = <<EOF
- Hello there, this is a multiline string variable in ruby!
- So far, I am absolutely LOVING the ruby language :D!
- It's Cool!
- EOF
- puts test
- g = Person.new("umby24")
- g.say_hi
- g.say_bye
- g.names = "umby"
- g.say_hi
- g.say_bye
- (10..15).each do |n|
- puts n
- end
- =begin
- Output of this program is:
- Ruby init..
- Hello there, this is a multiline string variable in ruby!
- So far, I am absolutely LOVING the ruby language :D!
- It's Cool!
- Hello umby24!
- Going so soon, umby24?
- Hello umby!
- Going so soon, umby?
- 10
- 11
- 12
- 13
- 14
- 15
- Ruby End...
- =end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement