Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlphonse Cuccurullo
2,513 PointsWhats it mean when it says string literal in condition? This is my code.
class Race
attr_reader :type,:name,:power,:speed attr_writer :type,:name,:power,:speed
def initialize(type,name,power,speed)
@type = type
@name = name
@power = power
@speed = speed
end
def summary
if @type == "sayian" || @name == "goku"
puts" This is a warrior race. Follow the legend of the supersayian "
puts"\n This is the sayian goku a very kind and ver poweful sayian. Like any sayian goku thirst's for battle but never let's that change his heart."
elsif
@type == "alien" || "frieza"
puts"This is the alien treat there is one tyrant known within universe 6 that is a alien."
puts" Frieza is a evil tyrant with un measurable power who rules the universe with his limitless power. He alone placed all of space in great fear."
elsif
@type == "namekian" || "piccollo"
puts"this is a very peaceful race"
puts"\n Piccollo is with out a doubt the strongest namekian. As prideful as the sayians piccollo is also intelligent and kind. Although kind is a gained trait \n piccollo use to be heartless until he met gohan."
elsif @type =="weeee"
puts" who the fuck is this guy ? "
end
end
end
goku = Race.new("sayian","goku",160,180) frieza = Race.new("alien","frieza",180,240) piccollo = Race.new("namekian","piccollo",100,80)
goku.summary
frieza.summary
piccollo.summary
sadpaul.summary
1 Answer
Theodore Karropoulos
22,149 PointsHello there,
It seems that you forgot the variable name at the or section of your elsif statement. Change
elsif @type == "alien" || "frieza" puts"
with
elsif @type == "alien" || @name == "frieza" puts"
Also i think that you might have to change the or || with and &&
Andrew Stelmach
12,583 PointsAndrew Stelmach
12,583 PointsPlease format your code so it's readable.