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
function () { | |
if (!this.$sizingHeader) return; | |
this.$element.prepend(this.$sizingHeader); | |
var $sizingCells = this.$sizingHeader.find('th'); | |
var columnCount = $sizingCells.length; | |
var tableWidth = $sizingCells.parent().width(); // Used to calculate the width percent | |
function matchSizingCellWidth(i, el) { |
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
func giveMeAStringMaybe(_ maybe: Bool) -> String? { | |
return maybe ? "Yes!" : nil | |
} | |
let str: String? = giveMeAStringMaybe(true) | |
if let unwrappedStr = str { | |
print(unwrappedStr is String) // prints: true | |
print(unwrappedStr) // prints: "Yes!" | |
} else { | |
print(str) // prints: nil |
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
func giveMeAStringMaybe(_ maybe: Bool) -> String? { | |
return maybe ? "Yes!" : nil | |
} | |
let str: String? = giveMeAStringMaybe(true) | |
guard let unwrappedStr = str else { | |
print("str is nil") | |
// unwrappedStr is NOT accessible here | |
return | |
} |
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
func giveMeAStringMaybe(_ maybe: Bool) -> String? { | |
return maybe ? "Yes!" : nil | |
} | |
let str1: String? = giveMeAStringMaybe(true) | |
let lowercaseStr1: String? = str1?.lowercased() | |
print(lowercaseStr2) // prints: "yes!" | |
let str2: String? = giveMeAStringMaybe(false) | |
let lowercaseStr2: String? = str2?.lowercased() |
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
let moveAction = SKAction.moveBy(x: 10, y: -15, duration: 0.8) |
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
let moveAction = SKAction.moveBy(x: 10, y: -15, duration: 0.8) | |
let player = SKSpriteNode(imageNamed: "player.png") | |
player.run(moveAction) |
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
let moveAction = SKAction.moveBy(x: 10, y: -15, duration: 0.8) | |
let rotateAction = SKAction.rotate(byAngle: π, duration: 0.5) | |
let moveAndRotate = SKAction.group([moveAction, rotateAction]) | |
let player = SKSpriteNode(imageNamed: "player.png") | |
player.run(moveAndRotate) |
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
let moveAction = SKAction.moveBy(x: 10, y: -15, duration: 0.8) | |
let player = SKSpriteNode(imageNamed: "player.png") | |
let moveFiveTimes = SKAction.repeat(moveAction, count: 5) | |
player.run(moveFiveTimes) |
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
let coin = SKSpriteNode(imageNamed: "coin.png") | |
let animate = SKAction.rotate(byAngle: π/2, duration: 0.75) | |
let updateScore = SKAction.run { | |
scoreValue += 10 | |
} | |
let sequence = SKAction.sequence([animate, updateScore]) | |
coin.run(sequence) |
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
let updateTimeLabel = SKAction.customAction(withDuration: 5) { | |
(node, elapsedTime) in | |
if let label = node as? SKLabelNode { | |
label.text = "\(elapsedTime)s" | |
} | |
} | |
let timeLabel = SKLabelNode(fontNamed: "Chalkduster") | |
timeLabel.text = "0s" | |
timeLabel.run(updateTimeLabel) |
OlderNewer