1. Home
  2. /
  3. Ruby
  4. /
  5. Classes and Inheritance

Classes and Inheritance - Ruby Typing CST Test

Loading…

Classes and Inheritance — Ruby Code

Shows how Ruby supports inheritance and method overriding in object-oriented programming.

class Animal
	def speak
		"Generic animal sound"
	end
end

class Dog < Animal
	def speak
		"Woof!"
	end
end

class Cat < Animal
	def speak
		"Meow!"
	end
end

animals = [Dog.new, Cat.new, Animal.new]

animals.each do |animal|
	puts animal.speak
end

Ruby Language Guide

Ruby is a dynamic, object-oriented, high-level programming language designed for simplicity, productivity, and readability. It emphasizes developer happiness and convention over configuration, widely used for web development, scripting, automation, and backend systems.

Primary Use Cases

  • ▸Web application development (Ruby on Rails, Sinatra)
  • ▸Backend APIs and microservices
  • ▸Automation and scripting
  • ▸Prototyping and MVPs
  • ▸DevOps tooling (Chef, Puppet)
  • ▸Data processing scripts

Notable Features

  • ▸Everything is an object
  • ▸Dynamic typing and duck typing
  • ▸Powerful metaprogramming and DSL support
  • ▸Elegant and readable syntax
  • ▸Convention over configuration (Rails)
  • ▸Large ecosystem and gems library

Origin & Creator

Created by Yukihiro 'Matz' Matsumoto in 1995 in Japan. Designed to maximize developer happiness by blending Perl, Smalltalk, Eiffel, Ada, and Lisp influences into an elegant, readable syntax.

Industrial Note

Ruby dominates web startups, SaaS platforms, rapid prototyping, automation, and DevOps tooling (Chef, Puppet). Ruby on Rails accelerates development, making it a top choice for MVPs and web platforms like GitHub, Shopify, and Basecamp.

More Ruby Typing Exercises

Ruby Blocks and IteratorsRuby Modules and MixinsRuby File HandlingRuby Exception HandlingRuby Hashes and SymbolsRuby Regular ExpressionsRuby Enumerables and MapRuby JSON ParsingRuby Time and Date Formatting

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#MqlCqlN1qlCypherGremlin