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 example in the documentation fails to compile. The error message is The type Person has 3 fields but the pattern expects 1 fields.
personinfo(person) = @match person begin
Person("Julia", lname, _) => "Found Julia $lname"
Person(fname, "Julia", _) => "$fname Julia was here!"
Person(fname, lname,
Address(_, "Cambridge", zip)) => "$fname $lname lives in zip $zip"
Person(_...) => "Unknown person!" # this line fails
The following change corrects the problem:
personinfo(person) = @match person begin
Person("Julia", lname, _) => "Found Julia $lname"
Person(fname, "Julia", _) => "$fname Julia was here!"
Person(fname, lname,
Address(_, "Cambridge", zip)) => "$fname $lname lives in zip $zip"
Person(_, _, _) => "Unknown person!"
end
or
personinfo(person::Person) = @match person begin
Person("Julia", lname, _) => "Found Julia $lname"
Person(fname, "Julia", _) => "$fname Julia was here!"
Person(fname, lname,
Address(_, "Cambridge", zip)) => "$fname $lname lives in zip $zip"
_ => "Unknown person!"
end
The text was updated successfully, but these errors were encountered:
The following example in the documentation fails to compile. The error message is
The type
Personhas 3 fields but the pattern expects 1 fields.
The following change corrects the problem:
or
The text was updated successfully, but these errors were encountered: