Le vendredi 20 mars 2015 à 14:03 -0700, Julia User a écrit : > I looked through some of the Base source code and see different things > for conversions. > > c%UInt8 > convert(UInt8,x) > UInt8(t) > > to name a few.... > > Any official recommendation for someone starting out new - anything > which is planned to be depreciate soon. I think all of them are OK, but the last one does not have the same behavior:
julia> UInt8(256) ERROR: InexactError() in call at base.jl:36 julia> convert(UInt8, 256) ERROR: InexactError() in convert at int.jl:160 julia> 256 % UInt8 0x00 The first one ends up calling the second one, so I'd say use it since it's shorter. The last one does not check for overflow, so use it only if you really want this behavior. In short: in doubt, use the first one. Regards
