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.
77707eb62b77a12638d1d0a9424afdc9?d=identicon&s=25 Nuno (Guest)
on 2006-05-13 11:09
Hello here !

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

or even

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

Be13d49ea40add75e564bef96b323caf?d=identicon&s=25 13 (Guest)
on 2006-05-13 11: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.