+ 8
How to print out what function returns in Swift?
In my code I have a function which returns one of the other functions chosen by an if statement. I wrote the code in the way I can tell what is returned. I printed the result I wanted but can it be done automatically. https://code.sololearn.com/cW1w2INxMrvZ/?ref=app
2 Respostas
+ 7
Don't be sorry. The main problem with this code is it is boring. I did everything *manually*. If I rewrite some part of it I will then need to rewrite the rest.
English is hard for me but I will try to explain.
var colors = ["red", "green", "blue"]
print(colors.count())
This prints out the number of colors *automatically* no matter what happens to the array.
0
I'm sorry. I don't understand what's the problem in what you're doing in the code. What do mean by 'can be *done automatically*'?