Last active
August 29, 2015 13:56
-
-
Save gavrix/8961770 to your computer and use it in GitHub Desktop.
objc NSDictionary literals vs c-style switch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSInteger sourceIntValue; | |
id mappedValue = (@{@(kSomeConstValue1): KSomeConstMappedValue1, | |
@(kSomeConstValue2): KSomeConstMappedValue2}[@(sourceIntValue)])?:KSomeConstMappedDefaultValue; | |
//VS | |
id mappedValue; | |
switch(sourceIntValue) { | |
case kSomeConstValue1: | |
mappedValue = KSomeConstMappedValue1; | |
break; | |
case kSomeConstValue2: | |
mappedValue = KSomeConstMappedValue2; | |
break; | |
default: | |
mappedValue = KSomeConstMappedDefaultValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment