concept instance in category ruby

appears as: n instance, instce, instces, instces, An instce, instce
The Well-Grounded Rubyist, Third Edition

This is an excerpt from Manning's book The Well-Grounded Rubyist, Third Edition.

A class defines an object’s functionality, and every object is an instance of exactly one class. Ruby provides a large number of built-in classes, representing important foundational data types (classes like String, Array, and Integer). Every time you create a string object, you’ve created an instance of the class String.

  • Instances of classes are objects, too.
  • A class object (like Ticket) has its own methods, its own state, and its own identity. It doesn’t share these things with instances of itself. Sending a message to Ticket isn’t the same thing as sending a message to fg or cc or any other instance of Ticket.
  • Listing 4.3. Creating and using an instance of class Stack
    s = Stack.new                           #1
    s.add_to_stack("item one")              #2
    s.add_to_stack("item two")              #2
    s.add_to_stack("item three")            #2
    puts "Objects currently on the stack:"
    puts s.stack                            #3
    taken = s.take_from_stack               #4
    puts "Removed this object:"
    puts taken
    puts "Now on stack:"
    puts s.stack
    Figure 4.1. An instance of class D looks for method x in its method search path.