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
int main(void) | |
{ | |
int h = get_positive_int("Height: "); // ask height and store it as i | |
printf("Stored: %i\n", h); //confirm value | |
for (int k = 1; k <= h; k++) | |
{ | |
for (int i = 1; i <= (h-k); i++) | |
{ | |
printf("."); |
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
int main(void) | |
{ | |
for (int i=0; i < 3; i++) | |
{ | |
for (int j=0; j<=i; j++) | |
{ | |
printf("#"); | |
} | |
printf("\n"); | |
} |
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
var kindOfAnimal = Animal(rawValue: "dinosaur").unwrappedOrUnknown |
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
enum Animal: String { | |
case unknown | |
case dog | |
case cat | |
} | |
extension Optional where Wrapped == Animal { | |
var unwrappedOrUnknown: Animal { | |
switch self { |
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
struct MyObject { | |
var myProperty: String? | |
} | |
extension Optional where Wrapped == MyObject { | |
var unwrappedOrInit: MyObject { | |
switch self { | |
case .some(let unwrapped): | |
return unwrapped |
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
tableView.register(MyCell.nib, forCellReuseIdentifier: MyCell. identifier) |
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 nib = UINib(nibName: "MyCell", bundle: nil) | |
tableView.register(nib, forCellReuseIdentifier: "MyCell") |
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
protocol CellRegistrable { | |
static var identifier: String { get } | |
static var nib: UINib { get } | |
} | |
extension CellRegistrable { | |
/// Defaults value to the name of the class | |
static var identifier: String { | |
return String(describing: Self.self) | |
} |
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
extension Optional where Wrapped == Int { | |
var unwrappedOrZero: Int { | |
switch self { | |
case .some(let unwrapped): | |
return unwrapped | |
case .none: | |
return 0 | |
} | |
} |
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
extension Optional where Wrapped == Bool { | |
var unwrappedOrFalse: Bool { | |
switch self { | |
case .some(let unwrapped): | |
return unwrapped | |
case .none: | |
return false | |
} | |
} |
NewerOlder