Permalink
Browse files

Merge pull request #2 from unu/master

LadyPHP updated
  • Loading branch information...
2 parents 74b9add + 523e542 commit af8618fe80af22b3ffb0470e4d4c1611fd34619e @juzna committed Aug 28, 2012
Showing with 214 additions and 228 deletions.
  1. +10 −8 examples/05-ladyphp/classes/Fruit.php
  2. +204 −220 examples/05-ladyphp/lady.php
@@ -1,23 +1,25 @@
<?
-# This should not be a .php file, but it is for the sake of autoloader
class Fruit
var apples = 0
var numbers = [
1: 'one',
2: 'two',
- 3: 'three',
+ 3: 'three'
]
fn addApples(n = 1)
- this.apples += n
+ if (n >= 0)
+ this.apples += n
return this
fn countApples()
apples = this.apples
out = 'You have '
- out .= isset(this.numbers[apples]) ? this.numbers[apples] : apples
- if (this.apples == 1)
- return out . ' apple.'
- else
- return "$out apples."
+ out .= isset(this.numbers[apples])
+ ? this.numbers[apples] : apples
+ switch (apples)
+ case 1
+ return out . ' apple.'
+ default
+ return "$out apples."
Oops, something went wrong.

0 comments on commit af8618f

Please sign in to comment.