I defined a function TestHead
in a notebook as follows:
TestHead[z___] := TrueQ[{z} == Cases[{z}, x_ /; Head[x] === avar]]
to test whether a bunch of variables all have a certain head avar
. When I do this in a notebook and define a variable a
using
a /: Head[a]=avar
this works fine and gives True
for TestHead[a]
. However, when I make a package
BeginPackage["TestHead`"]
TestHead::usage=""
Begin["`Private`"]
TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===avar]]
End[]
EndPackage[]
load the package and again define a variable a
as above, the function TestHead
now gives False
when acting on a
.
Why is this and how I can remedy it?