Which of the following adds a method to the Fixnum class that returns the number
ID: 3839620 • Letter: W
Question
Which of the following adds a method to the Fixnum class that returns the number of digits in a Fixnum object? A minus sign does not count as a digit.
class Fixnum
def num_digits
return self.abs.length
end
end
class Fixnum
def num_digits
return self.abs.to_s.length
end
end
class Fixnum
def num_digits
return self.length.abs.to_s
end
end
class Fixnum
def num_digits
return self.to_s.length
end
end
class Fixnum
def num_digits
return self.abs.length
end
end
class Fixnum
def num_digits
return self.abs.to_s.length
end
end
class Fixnum
def num_digits
return self.length.abs.to_s
end
end
class Fixnum
def num_digits
return self.to_s.length
end
end
Explanation / Answer
class Fixnum
def num_digits
return self.abs.to_s.length
end
end
This method is uaed to add required return statement to fixnum class.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.