[swift-users] while case and if case usage
Ramakrishna Mallireddy
ramakrishna.malli at gmail.com
Wed Feb 24 00:26:40 CST 2016
I am not sure if this helps, This is how I understand it.
what happens when you use normal switch.
switch someEnumExpression {
case someEnum.Element1: execute block / statements
default: executeDefault
}
// it checks each case with someEnumExpression, and if true then run it,
may be actual implementation might use dictionary with someEnum as Key
if case someEnum.Element1 == someEnumExpression {
execute block / statements
} else {
executeDefault
}
unroll your switch to if's, then I am sure you will understand its
construct...but why swift provide this control branch statements with case,
because at time I am sure that or only want to check an expression is of
particular enum case, then I use the if case like above. while is similar.
I am sorry if my explanation is vague.
On Wed, Feb 24, 2016 at 10:49 AM, Thomas# Chiang via swift-users <
swift-users at swift.org> wrote:
> have any document explain about "while case" and "if case" ? thank you ~
>
> TMS#
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160224/f551b97f/attachment.html>
More information about the swift-users
mailing list