Ruby Fundamentals
Ruby is an object-oriented, dynamically typed programming language. You write expressions, send messages to objects, organize code into methods, classes, and modules, and distribute reusable code as gems managed by Bundler.
itProgramming languages | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Intro
Ruby Fundamentals
Ruby is a general-purpose programming language in which every value is an object and most behavior is expressed by sending a method call to an object. A Ruby implementation reads source code, evaluates expressions, creates and manipulates objects, and performs effects such as writing a file or making a network request.
source file → parser → Ruby execution → objects + method calls → effects
The Ruby language and a particular implementation are different things. CRuby is the reference implementation commonly called Ruby, while JRuby and TruffleRuby run the language on different runtime systems. Code that relies on documented language behavior travels more easily than code coupled to one implementation's internals.
Everything is an object
Integers, strings, arrays, hashes, classes, and nil are objects. A method
call names a receiver and a method:
name = "Ada"
name.upcase
name is a local variable that refers to a String object. upcase is a
method sent to that object. The expression returns a new uppercase string;
it does not change name. Ruby convention uses a bang suffix for a method
that has a more dangerous counterpart. In core classes, that often means the
bang method mutates its receiver, but read the API rather than treating the
suffix as a language guarantee.
name.upcase! # changes the String object that name refers to
Assignment changes what a local variable refers to. Mutation changes the object itself. That distinction matters when two variables refer to one mutable object.
tags = ["ruby"]
alias_tags = tags
alias_tags << "language"
Both variables now observe two entries because << mutated one Array. Use
dup, clone, or a purpose-built copy when separate ownership is required.
A shallow copy does not duplicate objects nested inside a collection.
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://www.ruby-lang.org/en/documentation/
Supports
- Official Ruby documentation hub, reference manual, learning resources, tools, and editor ecosystem
- Ruby as a language with documentation for released versions
- https://www.ruby-lang.org/en/about/
Supports
- Ruby origin, public release history, language philosophy, and general-purpose positioning
- https://docs.ruby-lang.org/en/master/syntax.html
Supports
- Ruby syntax, literals, assignment, scope, control expressions, classes, modules, and methods
- https://docs.ruby-lang.org/en/master/syntax/methods_rdoc.html
Supports
- Method definitions, return values, arguments, keyword arguments, scope, and method naming conventions
- https://docs.ruby-lang.org/en/master/syntax/exceptions_rdoc.html
Supports
- Exception hierarchy, begin rescue ensure flow, and narrow error handling
- https://docs.ruby-lang.org/en/master/Enumerable.html
Supports
- Enumerable collection traversal, transformations, filtering, reductions, and lazy enumeration
- https://guides.rubygems.org/what-is-a-gem/
Supports
- Gem packaging, gemspec metadata, installation, and RubyGems ecosystem
- https://guides.rubygems.org/getting_started/
Supports
- Gemfile declarations, bundle installation, dependency resolution, and Gemfile.lock
- https://www.ruby-lang.org/en/news/2009/01/30/ruby-1-9-1-released/
Supports
- Ruby 1.9.1 release date and the stable Ruby 1.9 series
- https://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/
Supports
- Ruby 2.0 stable release, keyword arguments, Module prepend, and lazy enumeration
- https://www.ruby-lang.org/en/news/2017/12/25/ruby-2-5-0-released/
Supports
- Ruby 2.5 release date and language/runtime changes
- https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/
Supports
- Ruby 3.0 release date, Ractor, Fiber Scheduler, RBS, TypeProf, and performance direction
- https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/
Supports
- Ruby 3.2 release date and continuing runtime and language evolution
- https://github.com/markets/awesome-ruby
Supports
- Curated discovery of Ruby tooling including code analysis, testing, type checking, development tooling, and runtime implementations
- https://rubocop.org/
Supports
- Ruby static analysis and style enforcement
- https://rspec.info/
Supports
- RSpec behavior-focused testing framework
- https://sorbet.org/
Supports
- Sorbet gradual type checking for Ruby
- https://shopify.github.io/ruby-lsp/
Supports
- Ruby language server features for editor tooling
- https://pry.github.io/
Supports
- Pry interactive runtime inspection and debugging
- https://www.jruby.org/
Supports
- JRuby Ruby implementation on the Java virtual machine
- https://www.graalvm.org/ruby/
Supports
- TruffleRuby implementation on GraalVM
- https://mruby.org/
Supports
- mruby embeddable lightweight Ruby implementation
- https://rubygems.org/
Supports
- RubyGems package hosting and discovery
- https://bundler.io/
Supports
- Bundler dependency-management project
