@enum multiplication

Lincoln_Hannah
Wed, 03 Aug 2022 04:57:44 +0000
General Usage

Is this the best way to do this?

@enum BuySell (Buy=1; Sell=-1)

import Base.*
*(x::BuySell,  y::Any    )  = Int(x)   * y
*(y::Any,      x::BuySell)  = y        * Int(x)

Sell * 10    #  = -10

So I can put * Buy or * Sell in any equation.

13 posts - 4 participants