Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8772649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:05:14+00:00 2026-06-13T18:05:14+00:00

In my ruby class I have to make a user defined class with many

  • 0

In my ruby class I have to make a user defined class with many variables. SO far I’ve created a class relating to guitars and Ive looked over the code myself for a while and can’t figure out why I am getting errors on line 52/when I try to print out the examples to test the class

# Guitar
# Source code in /classes/person.rb

# Guitar class with instance variables @name, @brand, @type @strings and
# method take_strings.

class Guitar

  # initialize method is called when user invokes Guitar.new.
  def initialize(the_name, the_brand, the_type, the_strings)
    @name = the_name
    @brand = the_brand
    @type = the_type
    @strings = the_strings
  end

  # Define getters.
  def name
    return @name
  end

  def brand
    return @brand
  end

  def type
    return @type

  def strings
    return @strings
  end
.
  def strings=(value)
    @strings = value
  end

  def to_s
    return "#{name}; #{brand}; #{type}; #{strings}."
  end

end


guitars = [ ]

guitars << Guitar.new("Stratocaster", "Fender", "Solid Body", 6)
guitars << Guitar.new("Les Paul", "Gibson", "Solid Body", 6)
guitars << Guitar.new("White Falcon", "Gretsch", "Semi-Hollow, 6)

# Print all guitars
guitars.each do |g|
  print g, "\n"
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:05:15+00:00Added an answer on June 13, 2026 at 6:05 pm

    There are several things going on here:

    • On line 26, you do not have an end for your def type method
    • On line 32, you have a period in the source file; that’s not going to parse, and will cause issues.
    • On line 49, you’ve omitted a closing quote after Semi-Hollow
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: #!/usr/bin/ruby class Person def self.speak p = self.new puts
If I have the following piece of Ruby code: class Blah def self.bleh @blih
I have a ruby file as follows: module Example class Myclass def t_st Hello
I have a ruby method (deactivate!) that is on an activeRecord class. However, I
I have a ruby (1.9.3) on rails (3.1) app where: app/models/list.rb class List <
I am making a card game in ruby. I have the Game class, which
I'm using ruby 1.9.2 and rails 3.2.2. I have a 'domain' model (domain.rb): class
So I create a class in ruby: class User def initialize end end Now
I have a Ruby class called LibraryItem . I want to associate with every
Suppose I have a class in Ruby: class Test def method(arg1, arg2) return arg1+arg2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.