Ruby Tutorial

Read(14539) update time(2022-04-11)

Ruby is an open source server-side scripting language for object-oriented programming. It was designed and developed by Yukihiro Matsumoto in Japan in the mid-1990s. In the Ruby community, Matsumoto is also known as Matz. Ruby runs on multiple platforms such as Windows, MAC OS, and various versions of UNIX. "Ruby Tutorial", you will have a comprehensive understanding of Ruby.


Ruby is an object-oriented, imperative, functional, and dynamic general-purpose programming language. It was designed and developed by Japanese computer scientist Yukihiro Matsumoto (Matz) in the mid-1990s.

Comply with BSD license and Ruby License. Its inspiration and features come from Perl, Smalltalk, Eiffel, Ada, and Lisp languages. The Ruby language itself has also developed Ruby language alternatives for other platforms such as JRuby (Java platform) and IronRuby (.NET platform).

Ruby's Hello World program

The following is a simple program that outputs Hello World on the standard output device:

Example

#!/usr/bin/env ruby
puts "Hello, world!"

Run instance»

Click the "Run instance" button to view the online instance

Or in irb interactive command line mode:

Instance

>>puts "Hello, world!"

Hello, world!

=> nil

Run Instance»

Click the "Run Instance" button to view the online instance

Tips: Our Ruby tutorial will help you learn Ruby step by step. If you have any questions, please go to the PHP Chinese website Ruby Community to ask your questions. Some enthusiastic netizens will answer it for you.

Ruby language features

  • Completely object-oriented

  • In the Ruby language, everything is an object. Including basic data types in other languages, such as integers

  • Variables without type

  • Ruby variables can hold any type of data.

  • Everything has a value

  • Whether it is a mathematical or logical expression or a statement, it will have a value.

  • The ruby ​​language is very elegant and can be read without comments.

Ruby Advantages

  • Simple syntax

  • Ordinary object-oriented functions (classes, method calls Etc.)

  • ##Special object-oriented functions (Mixins, special methods, etc.)

  • ##Operator overloading
  • Error handling function
  • Iterators and closures
  • Garbage collection
  • Dynamic loading (Depending on the system architecture)
  • High portability. Not only can it run on most UNIX, but also on DOS, Windows, Mac, BeOS and other platforms
  • Suitable for rapid development, the general development efficiency is 5 times that of JAVA
  • Content covered by this Ruby tutorial manual

This Ruby tutorial manual Covers all basic and advanced knowledge of Ruby, including Ruby installation, Ruby environment variables, Ruby syntax, Ruby data types, Ruby classes and objects, Ruby variables, Ruby operators, Ruby methods, Ruby object-oriented, Ruby regular expressions, etc.

Tips:

Each chapter of this tutorial contains many Ruby examples. You can directly click the "Run Example" button to view the results online. These examples will help you better understand and use the Ruby language.

Latest chapter


Ruby RubyGems 2016-10-18
Ruby JSON 2016-10-18
Ruby 多线程 2016-10-18
Ruby Web Services 2016-10-18
Ruby XML, XSLT 和 XPath 教程 2016-10-18
Ruby Socket 编程 2016-10-18
Ruby 发送邮件 - SMATP 2016-10-18
Ruby CGI Sessions 2016-10-18