Complete the code to define a constant named GREETING inside the class.
class Welcome [1] = "Hello!" end
The constant name must start with a capital letter. Here, GREETING is the correct constant name.
Complete the code to access the constant PI inside the class MathConstants.
class MathConstants PI = 3.14 def self.get_pi [1] end end
Constants are accessed by their exact name. Inside the class method, PI refers to the constant.
Fix the error in accessing the constant MAX_SPEED from outside the class Vehicle.
class Vehicle MAX_SPEED = 120 end speed = [1]
In Ruby, constants from outside a class are accessed using the double colon :: operator.
Fill both blanks to define and access a constant SPEED_LIMIT inside the class Car.
class Car [1] = 80 def speed_limit [2] end end
The constant SPEED_LIMIT is defined and accessed by its name inside the class.
Fill all three blanks to create a constant NAME, access it inside a method, and access it from outside the class Person.
class Person [1] = "Alice" def name [2] end end puts [3]
The constant NAME is defined and accessed inside the class by its name, and from outside using Person::NAME.