[Gambas-user] Is the &= efficient?
Bruce
adamnt42 at gmail.com
Thu Mar 7 09:39:36 CET 2019
Inline.
On 7/3/19 6:41 pm, Rolf-Werner Eilert wrote:
>
> If it's only "1", I prefer Inc and Dec. But there is no "Inc x, 3" or
> "Inc(3) x" for instance, so I am forced to use +=.
Agreed. Inc x means Increment x.
Disagreed. Inc x, Sqrt(-1) or whatever.
>
> And last but not least, if there are more of these standing
> line-by-line, I would prefer += even for "1" to make it more clearly
> readable (for the reason above).
I find += (and all its friends) very useful. On a case by case basis!
An example. If we are doing a stepwise calculation involving references
to some other objects then
$iMystery = $iMystery + GetMagicNumber(CurrentIdx)
a lot easier to debug some months later than
$iMystery += GetMagicNumber(CurrentIdx)
Alternatively, if it is a "simplistic" calculation, such as say
Function HowOldWillIBeIn(Me as cOld, WhichYear as integer) as Integer
Return Me.Age += WhichYear ' ymmv depending on your birthdate
End
b
>
> Regards
> Rolf
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
More information about the User
mailing list