Forum: Ruby boolean affectation shortcut

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nuno (Guest)
on 2006-05-13 13:09
Hello here !

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

or even

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

13 (Guest)
on 2006-05-13 13:26
(Received via mailing list)

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

This topic is locked and can not be replied to.