btwael / mammouth

Unfancy PHP
http://mammouth.boutglay.com
MIT License
214 stars 22 forks source link

Assignage in if statement #17

Closed CezaryDanielNowak closed 10 years ago

CezaryDanielNowak commented 10 years ago
{{
  if !someVar
}}

works ok but this gives error:

{{
  if !result = someVar
}}
btwael commented 10 years ago

Use Parentheses  and a conditional operator (not '=' use '==' or '===' ...) like in http://mammouth.wamalaka.com/#try:{{%0Aif%28!result%20%3D%3D%20someVar%29%20%0A%20%20sdfsdf%0A}}

CezaryDanielNowak commented 10 years ago

I'm trying to achieve something like this:

{{
  something ->
    return(rand(0,3))

  if !test = something()
    echo('sorry, the result is 0')
    return(false)
  echo 'bravo! your result is ' test
}}

It's possible now, but in longer notation: if !(test = something())

btwael commented 10 years ago

yes, I hope that you are seen my comment in #18, but if you have any suggestions, be free to comment and open issue

btwael commented 10 years ago

you should use not operator Your example explain that.