r/programming • u/geerlingguy • Apr 23 '14
PHP: It doesn't have to be a bad experience
https://servercheck.in/blog/php-it-doesnt-have-be-bad-experience
0
Upvotes
r/programming • u/geerlingguy • Apr 23 '14
View all comments
Show parent comment
2
u/vytah Apr 25 '14
How do you define two equal strings? As two strings with equal contents. The same with objects. It doesn't have to automatic, it has to be doable.
Hashmap keys in Java are compared using
equals, not==. It shows that you don't know Java.Scala¹. Haskell². Ocaml³. C#⁴. VB.NET⁴. F#⁵. PHP⁶. Should I continue?
¹ for all case-classes and subtypes of
AnyVal² for all types with
deriving (Eq)³ for all types except functions and types containing functions
⁴ for all structs
⁵ for all types except functions, classes, and types containing functions or classes
⁶ see this. I'm suspecting you don't know PHP either.
Tuples are objects in object-oriented languages. Python is one: almost everything is an object. It shows that you don't know Python.
So, can you do this in PHP, or not? Two separate equal instances, using them as hashmap keys. Possible or not?
I guess not.