Is there a better way to write this?
@a = “abc”
@a = @b if @b
This will set value @a to @b if @b already have a value since before. If
not it will use the default @a which is “abc”.
Is there a better way to write this?
@a = “abc”
@a = @b if @b
This will set value @a to @b if @b already have a value since before. If
not it will use the default @a which is “abc”.
On Oct 15, 2010, at 3:07 PM, Paul B. wrote:
Is there a better way to write this?
@a = “abc”
@a = @b if @b
This will set value @a to @b if @b already have a value since
before. If
not it will use the default @a which is “abc”.
If I understand you, this will do that:
@a = @b || “abc”
-Rob
Rob B.
[email protected] http://AgileConsultingLLC.com/
[email protected] http://GaslightSoftware.com/
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs