0

what is fallthrough in swift ? why it is used?

8th Aug 2016, 5:00 AM
Rahul Sharma
Rahul Sharma - avatar
2 Réponses
0
Seems to allow for calling the next case, even if the object doesn't match by search parameter. Cant think of a use case for it...
9th Aug 2016, 3:58 AM
SouthBay
SouthBay - avatar
0
Fallthrough is when a switch executes a case then "falls through" to execute the next case in the same switch. In some languages this happens by default and can be prevented with "break." However, in Swift the default is *not* to fall through; instead just one case executes unless you explicitly direct it to fallthrough. An example is if you have a switch with five cases and you want to skip the first two and execute all of the last three. You could execute case three and then fall through to execute the subsequent two cases as well.
14th Aug 2016, 8:54 PM
Mike
Mike - avatar