I was coding something today, and I have a variable
V which can be of many types (
Float64, and so on). However, I need to limit the value of this variable. What I did was:
V > +10 && (V = eltype(V)(+10)) V < -10 && (V = eltype(V)(-10))
However I found this strange… So, I would like to propose the indrocution of broadcast operator for such primitive types, so that we can do:
V .= 10
and V will not change type. Of course, if conversion is not possible, then an error will be thrown.
What do you think?
EDIT: I know we have the
sign function that would do what I need, but I still think this will be nice to have.