How to install ruby in Android using Termux

What is ruby ?

A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

How to install ruby ?

Open terminal and type following commands.

$ apt update
$ apt install ruby

Open note editor and write hello world ruby program.

$ nano hello.rb

# The Greeter class
class Greeter
  def initialize(name)
    @name = name.capitalize
  end

  def salute
    puts "Hello #{@name}!"
  end
end

# Create a new object
g = Greeter.new("world")

# Output "Hello World!"
g.salute

To run ruby program type :
$ ruby hello.rb

Hello world!

You can run any ruby programme in termux on Android smartphone.

Comments

Post a Comment