Last active
August 29, 2015 14:04
-
-
Save kaiwren/c7b4a17aa73b0be45b22 to your computer and use it in GitHub Desktop.
RubyMonk Example with output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Great I will check when I get home on my command prompt
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
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.