OneBite.Dev - Coding blog in a bite size

declare an object in Ruby

Code snippet on how to declare an object in Ruby

  person = { 
    :name => "John Doe", 
    :age => 50
  } 

This code first creates an object “person” as a hash with two keys, :name and :age, and sets the values for each key. The :name has a value of “John Doe” and :age has a value of 50. A colon (:) symbol is used to represent the key. This is the fundamental syntax for declaring an object in Ruby.

ruby