You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following definition of + for a Vol type representing an N-dimensional volume should (I believe) call the parametrised + method when the two Ns are the same; however, it calls the catch-all method that is designed for Vol objects with different N (EDIT: i.e. those not covered by the more restricted method definition):
immutable Vol{N,T<:Real}
value::TendVol{T}(N, x::T) =Vol{N,T}(x)
import Base.++(V1::Vol, V2::Vol) =throw(ArgumentError("Volumes of different dimension cannot be added"))
+{N,T}(V1::Vol{N,T}, V2::Vol{N,T}) =Vol{N,T}(V1.value + V2.value)
V1 =Vol(3, 2)
V2 =Vol(3, 4)
julia> V1 + V2
ERROR: ArgumentError: Volumes of different dimension cannot be added
in+ at none:1
The text was updated successfully, but these errors were encountered:
The following definition of
+
for aVol
type representing anN
-dimensional volume should (I believe) call the parametrised+
method when the twoN
s are the same; however, it calls the catch-all method that is designed forVol
objects with differentN
(EDIT: i.e. those not covered by the more restricted method definition):The text was updated successfully, but these errors were encountered: