Permalink
Browse files

Final update to ruby-objects lesson notes.

  • Loading branch information...
deconstructionalism
deconstructionalism committed Jul 6, 2018
1 parent 318250d commit 90f5ab7cd58e2db4db27b0bd24bf960b2044cac3
Showing with 27 additions and 3 deletions.
  1. +27 −3 ruby-object/README.md
  2. BIN ruby-object/ruby-object_notes.pdf
@@ -91,10 +91,34 @@ By the end of this, developers should be able to:
const fido = new Dog('Fido', 'Dobberman')
```

#### Lab Code
#### Javascript Classes vs Ruby Classes

- **Javascript** class:

- will be inserted after lesson
- ```js
// code goes here
class Rectangle {
constructor(length, width) {
this.length = length
this.width = width
}
area () {
return this.length * this.width
}
}
```
- **Ruby** class:
- ```ruby
class Rectangle
def initialize(length, width)
@length = length
@width = width
end
def area
@length * @width
end
end
```

- Notice how similar the **Javascript** class syntax is to the **Ruby** class syntax. In fact, they are almost directly translatable from one to the other, simply by replacing keywords and block demarcations.
BIN +3.13 KB (110%) ruby-object/ruby-object_notes.pdf
Binary file not shown.

0 comments on commit 90f5ab7

Please sign in to comment.