Skip to content

Instantly share code, notes, and snippets.

@kaiwren
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaiwren/c7b4a17aa73b0be45b22 to your computer and use it in GitHub Desktop.
Save kaiwren/c7b4a17aa73b0be45b22 to your computer and use it in GitHub Desktop.
RubyMonk Example with output
class Rectangle
def initialize(length, breadth)
@length = length
@breadth = breadth
end
def perimeter
2 * (@length + @breadth)
end
def area
@length * @breadth
end
end
rectangle = Rectangle.new(5, 2)
puts rectangle.perimeter
puts rectangle.area
@Lorrainehope98
Copy link

Put this code into my ruby command line. How would I return a value on perimeter and area - I have also asked on https://www.facebook.com/groups/1511546299060359/ learning Ruby where I have posted this code.

@Lorrainehope98
Copy link

Great I will check when I get home on my command prompt

@Lorrainehope98
Copy link

That's brilliant 14 and 10 are returned on the command line. Thanks Sidu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment