Skip to content

Instantly share code, notes, and snippets.

@stevef
Last active January 4, 2017 18:56
Show Gist options
  • Save stevef/a84621fbde01a26c6ec6791bb83583de to your computer and use it in GitHub Desktop.
Save stevef/a84621fbde01a26c6ec6791bb83583de to your computer and use it in GitHub Desktop.
// my bad code
if let packetType = packet["Type"] {
if let nPacketType = Int(packetType) {
if nPacketType == 20 {
receivedSessionState(packet: packet, jsonBody: jsonBody)
}
}
}
// freenode better code
if let packetType = packet["Type"], Int(packetType) == 20 {
receivedSessionState(packet: packet, jsonBody: jsonBody)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment