Reputation: 33
I see a below syntax in one of the ruby files written by an user. Can someone help me in understanding what the below code means?
if fieldWidth==nil
fW = regStr.length
else
fW = fieldWidth
regStr.rjust(fW,'0') # Left pad with 0s if fW > regStr.length
end
if fW >= fWOld: fWMax = fW end
fWOld = fW
regStrIx = 0
Upvotes: 0
Views: 79
Reputation: 80105
In the context of the if conditional, a footnote in The Ruby Programming Language on page 119 : "Ruby 1.8 also allows a colon, but this syntax is no longer legal in 1.9."
A newline or semicolon or the keyword then
is correct.
Upvotes: 4