Boolean affectation shortcut

Hello here !

I wonder why I can’t use these statements :
new_image? = (filesize > 0)

or even

new_image? = (filesize > 0 ? true : false)

Thanks

Hi,

You can’ t because only methods can end with ?, but you are using it
like a variable.
Looks, like you need to rethink your programs design.

Maybe something like this:

class Image

def new_image?
filesize > 0
end

end


Martins

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs