Ruby
Script extension is .rb
Used online IDE http://www.tutorialspoint.com/execute_ruby_online.php
--------------------------------
# Hello World
puts "Hello World!";
Hello World!
# The Hello Class
class Hello
def initialize( name )
@name = name.capitalize
end
def salute
puts "Hello #{@name}!"
end
end
# Create a new object
h = Hello.new("Ruby")
# Output "Hello Ruby!"
h.salute
Hello Ruby!
--------------------------------
Script extension is .rb
Used online IDE http://www.tutorialspoint.com/execute_ruby_online.php
--------------------------------
# Hello World
puts "Hello World!";
Hello World!
# The Hello Class
class Hello
def initialize( name )
@name = name.capitalize
end
def salute
puts "Hello #{@name}!"
end
end
# Create a new object
h = Hello.new("Ruby")
# Output "Hello Ruby!"
h.salute
Hello Ruby!
--------------------------------
No comments:
Post a Comment