Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Root825576yAnd this is why I dislike heavily-enforced strong typing. (C-style types are fine, but past that they get increasingly irritating)
I remember getting an error in VB when I was like 10 stating some ridiculously long type consisting of s chain of objects (like "...blah.blah.ocx.blah.commonctl.blah.blah.TextBox.text") was not a string.
I much prefer Ruby's typing. Everything still has strong types, but converting between them is often easy, and Ruby allows "duck typing." This means if something looks like it's e.g. an enumerable, you can use enumerable methods on it. As an example: you can use the same methods to iterate over a Hash, array, string, ARel results set, range, .... -
Of course substring is not a string because strings are value types in Swift, and you don't want to cause a copy before you're done. Besides, substring references the original memory, so if you keep going with that, the original string can't be garbage collected as long as the substring is around.
That's why substring is only used for intermediate operations, and when you're done, you stringify that. -
Actually, strings always suck one way or the other, and that's because strings are a hard problem. Even worse now with unicode and graphems and stuff.
Related Rants
"/path/to/my/file.swift:143:34: error: cannot convert return expression of type 'String.SubSequence' (aka 'Substring') to return type 'String'"
Ah yes, I love it when Substring isn't String
rant
swift