Monday, July 27, 2015

Linked Lists, Enums, Value Types and Identity

Airspeed Velocity (tweet):

So, with our nodes being references, we essentially got a free globally-unique identifier for each one, which we could then use to implement node equality. But now that we have switched away from box, we can’t use === any more. So what can we do?

[…]

Finally, a third option: tag our list elements with a number, and use that to compare them.

I hope there’s a better way.

2 Comments RSS · Twitter

Embrace the computing advances of the 1960's and use an array.

I know, functional programming. But swift is not lisp. You don't need linked lists and they're generally a bad idea. You can be functional and simplify your life.

@Chris I don’t see the article as recommending linked lists, but rather using lists as a simple example to discuss these concepts. The next step would be trees, which have their uses, and where the integer tagging solution falls apart.

Leave a Comment