Programmers learn any new language and always start by writing a Hello World in a new language, and we are no exception to writing a minimalist Hello world with Ruby first.
Say minimalism deserves to be deserved because there is only one line of code:
<span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:18PX;" >puts "Hello, ruby!"; </span>
Save the above code to the Helloworld.rb file (the Ruby script suffix is. rb), and then execute Ruby helloworld.rb, and you'll see a print on the command line hello, ruby!
Of course, you can also choose not to use the file, directly using IBR, enter the above line of code, the return can see the effect.
Here is a brief introduction to IBR, because for beginners, this should be a tool that needs to be used frequently in the next study. IBR refers to interactive Ruby, which, in particular, will be processed as soon as you enter the corresponding script source code. When you open IBR, you will see a hint of IBR (main):001:0>, 001 means that 001 rows are currently in line, and the next 0 indicates that you are currently in level 0 code depth. Of course, these are not important for now, in the subsequent use is easy to understand, now we just go to use it, to do a simple statement on it, than if: puts "Hello, ruby!"
"Ruby Learning Notes" Hello world