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
-
You know what I did in order to get a for loop like this? This
var arrayFrom5To0: [Int] = [5,4,3,2,1,0]()
for i in arrayFrom5To0 {
//do shit
} -
I thought swift was the most beloved language by its users, saw a survey of developers.
-
@eternalfool Thats all just BS, trust me, if you look at devRants own stats, you'll see that swift devs rant the most
-
@bhargav-mogra I read an article about the success of devrant and at the time of writing, SQL devs won that(most rants) title.
-
@0xcaff if youre gonna use an array anyway why not just initialize the array in reverse order rather than do the complicated lenth-1-fakei?
-
0xcaff3508y@livecoder What if your input isn't reversed? What if your source is immutable and you don't want to copy your array just to reverse it?
-
spunky6678yI ran into a similar issue a while back and was as frustrated as you especially because I came from the lovely world of pointers 😉
Since stride is no longer an option, then why not just do a reverse while loop instead?!
var maxElement: Int = 5
while maxElement > 0
{
// do shit
maxElement -= 1
}
Hope it helps! Cheers mate!!! -
@spunky yes or either do that lol which is probably the correct way, but a for loop is much more readable for these kind of things
-
Cube18929268y@HTahboub How long ago? I tried Swift 1 when it was new and couldn't write a line of Swift 2 code without an error or a warning a few months ago (I decided to play with Xcode again). I hear Swift 3 even changes things Swift 2 changed...
-
@Cube189 haha, well I'm pretty much like you, tried swift 1 thought it was ok, sasw swift 2 in wwdc, got disappointed...
-
@liveCoder it actually developers, but I think that your misconception suits it better.
-
Ahaha, I just heard from my boss that IBM's core swift contributors will be coming to Bangalore next Jan, I'm going to fuck them up so bad!
-
@TheInitializer yes thats what I did finally using a while loop, its very easy to simulate a for loop with a while loop, downside being you have to write 2-3lines of extra code
-
rebus06yTotally agree with your rant. Swift is over conceptualized ugly language. Joined devRant just for the Swift hate. And I (used to) love Apple. Swift killed my desire to code for iOS/macOS ever!
-
mega24011yyes I was forced to use swift in some project and it looks like the worst crap programming language every created, shame and waste of time. non documented and buggy. for instance, I spent 5 hours to try to understand how to navigate with a button between "views". There is no way... everything is bad, badly designed, badly done and crappy.
Related Rants
Swift, oh my god, why do you have to be like this?
I'm looking to write a simple for loop like this one in java
for(int i = 5; i > 0; i--) {
// do shit
}
Thats it, simple, go from 5 to 1 (inclusive), I saw that to iterate over a range in a for loop (increasing ordeR) I can do this
for i in 0...5 {
// do shit.
}
So I thought maybe I could do this to go in reverse (which seems logical when you think about it doesn't it?)
for i in 5..<0 {
// do shit
}
But no, this compiles FINE (THIS IS THE FUCKING KICKER IT COMPILES), alright, when you the code runs you get a fucking exception that crashes the mother fucking application, and you know what the problem is?? This dogshit, shitStain of a language doesn't like it when integer that the for loop starts with is larger than the integer that the for loop ends with MOTHERFUCKER ATLEAST TELL ME THAT AT COMPILE TIME AS A MOTHERFUCKING WARNING YOU PIECE OF SHIT!!
Alright *deep breathing*, now we can't just be stuck on this raging, we're developers need to move forward, so I google this, "Swift for loop in reverse" fair enough I get a straight forward answer that tells me to use the `stride` functionality. The relevant code for it
for i in stride(from:5 to:1 by:-1) {
// do shit
}
Wow looks fine and simple right?? (looks like god damn any other language if you ask me, no innovations here piece of shit apple!) WRONG BITCHES !!! In the latest version of Swift THE FUCKING DEVELOPERS DECIDED TO REMOVE STRIDE ALTOGETHER, WITHOUT ADDING IN A GOOD REPLACEMENT FOR THAT SHIT!
Alright NOW IM FUCKING MAD, I got rage on stackoverflow chat, a guy who's been working on ios for quite a while comes up n says and I quote
"I can sort of figure it out, but besides that, iterating in reverse is uncommon enough that it probably hasn't crossed anyone's mind."
Now hope you guys understand my frustration, and send me cookies to calm me down.
Thank you for listening to me !
undefined
swift-is-shit