Skip to content

Commit a394c3a

Browse files
authored
Update introduction.md (#615)
Add a note about the use of `$this`. It's needed to be able to solve the first exercise, and people coming from other languages (eg C++) may not realize it's required rather than optional.
1 parent 06ad849 commit a394c3a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

exercises/concept/lasagna/.docs/introduction.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ class Calculator {
4848
}
4949
```
5050

51+
To call a method from another method of the same class, you need to use the `$this` variable:
52+
53+
```php
54+
function subtract($x, $y)
55+
{
56+
return $this->add($x, -$y);
57+
}
58+
```
59+
5160
### Naming conventions
5261

5362
Classnames should all be `PascalCase`.

0 commit comments

Comments
 (0)