3 added 18 characters in body
source | link

ItsIt's because avar is in TestHead Privatethe TestHead`Private` context. One fix is to write your package with an explicit context on avar, such as Global.Global`:

TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global`avar]]

You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False:

Trace@TestHead[a]

(*
{TestHead[a],TrueQ[{a}==Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]
===TestHead`Private`avar]],
{{Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]===
TestHead`Private`avar],{{Head[a],avar},avar===TestHead`Private`avar,False},{}},
{a}=={},False},TrueQ[False],False}
*)

Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global.

TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global`avar]]

You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False:

Trace@TestHead[a]

(*
{TestHead[a],TrueQ[{a}==Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]
===TestHead`Private`avar]],
{{Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]===
TestHead`Private`avar],{{Head[a],avar},avar===TestHead`Private`avar,False},{}},
{a}=={},False},TrueQ[False],False}
*)

It's because avar is in the TestHead`Private` context. One fix is to write your package with an explicit context on avar, such as Global`:

TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global`avar]]

You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False:

Trace@TestHead[a]

(*
{TestHead[a],TrueQ[{a}==Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]
===TestHead`Private`avar]],
{{Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]===
TestHead`Private`avar],{{Head[a],avar},avar===TestHead`Private`avar,False},{}},
{a}=={},False},TrueQ[False],False}
*)
2 added 488 characters in body
source | link

Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global.

TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global`avar]];Head[x]===Global`avar]]

You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False:

Trace@TestHead[a]

(*
{TestHead[a],TrueQ[{a}==Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]
===TestHead`Private`avar]],
{{Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]===
TestHead`Private`avar],{{Head[a],avar},avar===TestHead`Private`avar,False},{}},
{a}=={},False},TrueQ[False],False}
*)

Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global.

TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global`avar]]

Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global.

TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global`avar]]

You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False:

Trace@TestHead[a]

(*
{TestHead[a],TrueQ[{a}==Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]
===TestHead`Private`avar]],
{{Cases[{a},TestHead`Private`x_/;Head[TestHead`Private`x]===
TestHead`Private`avar],{{Head[a],avar},avar===TestHead`Private`avar,False},{}},
{a}=={},False},TrueQ[False],False}
*)
1
source | link

Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global.

TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global`avar]]