RosettaCodeData/Task/Classes/CoffeeScript/classes.coffee

15 lines
267 B
CoffeeScript
Raw Permalink Normal View History

2013-04-09 00:46:50 -07:00
# Create a basic class
class Rectangle
# Constructor that accepts one argument
constructor: (@width) ->
# An instance variable
length: 10
# A method
area: () ->
@width * @length
# Instantiate the class using the new operator
rect = new Rectangle 2