YouTip LogoYouTip

Ruby Tutorial - Getting Started

Ruby Basics

name = "Alice"
puts "Hello, #{name}!"

[1, 2, 3].each { |n| puts n }

def greet(name)
    "Hello, #{name}!"
end

Classes

class Person
    attr_accessor :name, :age
    def initialize(name, age)
        @name = name
        @age = age
    end
end

Summary

  • Ruby emphasizes developer happiness
  • Everything is an object
← Kotlin Tutorial - Getting StarPHP Tutorial - Getting Started β†’