Last active
August 29, 2015 14:02
-
-
Save cieslak/ae4dd4dc3da5f9027274 to your computer and use it in GitHub Desktop.
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
class Team { | |
let cityName: String | |
let teamName: String | |
let shortName: String | |
var fullName: String { | |
get { | |
return cityName + " " + teamName | |
} | |
} | |
init(var cityName: String, teamName: String, var shortName: String) { | |
if (cityName == "NY Rangers" || cityName == "NY Islanders") { | |
cityName = "New York" | |
} | |
if (shortName == "" && countElements(cityName) >= 3) { | |
shortName = cityName.substringToIndex(3).uppercaseString | |
} | |
self.cityName = cityName | |
self.teamName = teamName | |
self.shortName = shortName | |
} | |
class func teamFromJSON(dict: Dictionary<String, AnyObject>, home: Bool) -> Team? { | |
let keys = home ? (dict["homeTeamCity"], dict["homeTeamName"], dict["shortAwayTeam"]) : | |
(dict["awayTeamCity"], dict["awayTeamName"], dict["shortAwayTeam"]) | |
switch keys { | |
case (.Some(let theCity as String), | |
.Some(let theName as String), | |
.Some(let theShortName as String)): | |
return Team(cityName:theCity, teamName:theName, shortName:theShortName) | |
default: | |
return nil | |
} | |
} | |
} | |
/* returns this from the compiler when the switch in teamFromJSON is not commented out: | |
Bitcast requires both operands to be pointer or neither | |
%182 = bitcast i8* %181 to %SS, !dbg !198 | |
Invalid operand types for ICmp instruction | |
%183 = icmp ne %SS %182, null, !dbg !198 | |
PHI nodes must have at least one entry. If the block is dead, the PHI should be removed! | |
%186 = phi i32 , !dbg !199 | |
PHI node operands are not the same type as the result! | |
%185 = phi i8* [ %182, %178 ], !dbg !199 | |
Bitcast requires both operands to be pointer or neither | |
%196 = bitcast i8* %195 to %SS, !dbg !203 | |
Invalid operand types for ICmp instruction | |
%197 = icmp ne %SS %196, null, !dbg !203 | |
PHI nodes must have at least one entry. If the block is dead, the PHI should be removed! | |
%200 = phi i32 , !dbg !199 | |
PHI node operands are not the same type as the result! | |
%199 = phi i8* [ %196, %192 ], !dbg !199 | |
Bitcast requires both operands to be pointer or neither | |
%210 = bitcast i8* %209 to %SS, !dbg !207 | |
Invalid operand types for ICmp instruction | |
%211 = icmp ne %SS %210, null, !dbg !207 | |
PHI nodes must have at least one entry. If the block is dead, the PHI should be removed! | |
%214 = phi i32 , !dbg !207 | |
PHI node operands are not the same type as the result! | |
%213 = phi i8* [ %210, %206 ], !dbg !207 | |
LLVM ERROR: Broken function found, compilation aborted! | |
Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 1 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment