I know in PHP you have to intrepret a page like index.php, but in Ruby how does it work? I don't know what is the Ruby extension like index.php for PHP. Could you help me?
Writing Code rb that you created, you need to write a single line of code that prints the string Hello World! to your terminal. To print in Ruby, you need to use the method puts which is short for "out*put s*tring." And because Hello World! is a string, you need to surround your text with "" . puts "Hello World!"
If you are talking about a command line program this will work.
puts "Hello World"
or if you want an object oriented version
class HelloWorld def initialize(name) @name = name.capitalize end def sayHi puts "Hello #{@name}!" end end hello = HelloWorld.new("World") hello.sayHi
If you are looking for a ruby on rails version of Hello World. Check the Getting Started Guide for Rails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With