Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the single less than in a ruby class

Tags:

ruby

Example:

class YourName < Library::Method
  # code in here
end

I see it all the time in ruby and I have no idea what it means.

like image 880
ZucchiniZe Avatar asked Dec 01 '14 10:12

ZucchiniZe


People also ask

What are classes in Ruby?

What is a class in Ruby? Classes are the basic building blocks in Object-Oriented Programming (OOP) & they help you define a blueprint for creating objects. Objects are the products of the class.

What is base class in Ruby?

But from Ruby 1.9 version, BasicObject class is the super class(Parent class) of all other classes in Ruby. Object class is a child class of BasicObject class. Syntax: subclass_name < superclass_name. Example: Ruby.

What is class and instance in Ruby?

In Ruby, a class is an object that defines a blueprint to create other objects. Classes define which methods are available on any instance of that class. Defining a method inside a class creates an instance method on that class. Any future instance of that class will have that method available.

How do you inherit a class in Ruby?

In Ruby, single class inheritance is supported, which means that one class can inherit from the other class, but it can't inherit from two super classes. In order to achieve multiple inheritance, Ruby provides something called mixins that one can make use of.


1 Answers

This is the inheritance operator (<)

It means "YourName inherits from Library::Method"

like image 112
Uri Agassi Avatar answered Sep 29 '22 07:09

Uri Agassi