- Home /
Why does CompareTag exist?
.tag ==
CompareTag()
I don't understand why the latter exists.
Answer by Eric5h5 · Jan 02, 2011 at 08:24 PM
I wondered that myself before, since CompareTag seems more cumbersome. Turns out it's faster and doesn't allocate memory like string comparisons do. (Now if only I would stop forgetting that it exists....)
TBH, I never knew it existed until just now! Interesting (albeit see$$anonymous$$gly superfluous) option.
As I mentioned, it's not superfluous. The docs should explain why it exists though.
Ah, I always wondered about that too. (The performance issues you mentioned don't seem to be mentioned in the documentation though.)
Oh, haha. I read 'the docs should explain' as 'if you check the docs, you should find the information there', not as, 'the docs should explain, but they don't' :) I follow you now though.
I read the same thing, @Jesse. But I think, more so, the docs should say it's "deprecated because it's already automatically implemented when using .tag ==
"... $$anonymous$$aybe some day in the future. :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613093717im_/https://answers.unity.com/themes/thub/images/avi.jpg)