if statement - Why postfix `if` in Ruby work so strange -


i have follows strange behaviour in ruby:

var1.zero? if var1 = 1 

nameerror: undefined local variable or method var1 main:object

from other side, if same thing in standard if, works expected:

if var1 = 1   var1.zero? end # => false 

anyone can describe how work postfix if in ruby?

because if ask you

isn't daughter cute...

you interrupt me with

you have daughter?

before finish initial sentence was

isn't daughter cute, [showing picture]?


but if ask you

[showing picture] daughter, isn't cute?

you can respond

no


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -