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 SuperHeroDetailViewControllerTests: XCTestCase { | |
private let repository = MockSuperHeroesRepository() | |
/* ... */ | |
private func openSuperHeroDetailViewController(_ superHeroName: String) { | |
let superHeroDetailViewController = ServiceLocator() | |
.provideSuperHeroDetailViewController(superHeroName) as! SuperHeroDetailViewController | |
superHeroDetailViewController.presenter = SuperHeroDetailPresenter(ui: superHeroDetailViewController, |
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 SuperHeroDetailViewControllerTests: XCTestCase { | |
private let repository = MockSuperHeroesRepository() | |
/* ... */ | |
private func openSuperHeroDetailViewController(_ superHeroName: String) -> UIViewController { | |
let superHeroDetailViewController = ServiceLocator() | |
.provideSuperHeroDetailViewController(superHeroName) as! SuperHeroDetailViewController | |
superHeroDetailViewController.presenter = SuperHeroDetailPresenter(ui: superHeroDetailViewController, |
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 SuperHeroesControlsViewControllerTests: AcceptanceTestCase { | |
func testShowsEmptyCaseIfThereAreNoSuperHeroes() { | |
openSuperHeroesViewController() | |
tester().tapView(withAccessibilityLabel: "Button") | |
tester().setValue(0, forSliderWithAccessibilityLabel: "Slider") | |
for _ in (0..<10) { |
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
// --------------------------------------------- // | |
// -------------- VIEW CONTROLLER -------------- // | |
// --------------------------------------------- // | |
import UIKit | |
class SuperHeroControlsViewController: UIViewController { | |
var textField: UITextField! | |
var slider: UISlider! |
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
[alias] | |
# ronto stands for "rebase --onto". Uses the current branch to move it and updates the start-of-the-branch tag along | |
ronto = "!f() { \ | |
git rebase --onto $1 __start__$(git rev-parse --abbrev-ref HEAD) $(git rev-parse --abbrev-ref HEAD); \ | |
git tag -d __start__$(git rev-parse --abbrev-ref HEAD); \ | |
git tag __start__$(git rev-parse --abbrev-ref HEAD) $1; \ | |
}; f" | |
# nb stands for "create branch". Creates a tag marking the start-of-the-branch | |
cb = "!f() { \ | |
git tag __start__$1; \ |
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
tailrec fun fizzbuzz(vararg args: Int) { | |
if (args.isEmpty()) return | |
val arg = args[0] | |
when { | |
arg % 15 == 0 -> print("FizzBuzz") | |
arg % 3 == 0 -> print("Fizz") | |
arg % 5 == 0 -> print("Buzz") | |
} |
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
fun sum1(a: Int?, b: Int?): Int { | |
b ?: return 0 | |
return if (a != null) { | |
a + b | |
} else { | |
5 + b | |
} | |
} |
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
abstract class Product( | |
val id: String | |
) { | |
abstract val name: String | |
abstract var priceInEuros: Int | |
var priceInDollars: Int | |
get() = (priceInEuros * 1.06).toInt() | |
set(value) { | |
priceInEuros = (value / 1.06).toInt() | |
} |
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
interface Sellable { | |
var priceInEuros: Int | |
var priceInDollars: Int | |
get() = (priceInEuros * 1.06).toInt() | |
set(value) { | |
priceInEuros = (value / 1.06).toInt() | |
} | |
} | |
interface Describable { |
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
sealed class Vinyl { | |
object Skull : Vinyl() | |
data class Angels(val numberOfAngels: Int) : Vinyl() | |
data class Flowers(val numberOfFlowers: Int) : Vinyl() | |
data class Guns(val label: String) : Vinyl() | |
object Boots : Vinyl() | |
} | |
typealias Flag = Color |
OlderNewer