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 Animal { | |
func makeNoise() { | |
print("Unknown animal!") | |
} | |
} | |
class Dog: Animal { | |
override func makeNoise() { | |
print("The dog goes woof!") | |
} |
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 makeNoise(animal: Animal) { | |
switch animal { | |
case let dog as Dog: | |
print("The dog goes woof!") | |
case let cat as Cat: | |
print("The cat goes meow!") | |
case let bird as Bird: | |
print("The bird goes tweet!") | |
default: | |
print("Unknown animal!") |
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 multiplyNumbers(_ firstNumber: Int, by secondNumber: Int) -> Int { | |
return firstNumber * secondNumber | |
} |
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 foo(a: Int, b: Int) -> Int { | |
return a * 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
// Initializes i with zero | |
int i = 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
# Check if a user has an "admin" type | |
def check_admin_permission(user): | |
if user.type == 'admin': | |
return True | |
else: | |
return False |
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
# Calculates the mean of a list of numbers | |
def calculate_mean(numbers): | |
total = sum(numbers) | |
return total / len(numbers) |
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 that calculates the average of a list of numbers | |
# Version 2.0, updated on 2022-05-01 by João Silva | |
# Last modification: 2022-05-01 14:30:00 (Brasilia time) | |
def calculate_mean(numbers): | |
total = sum(numbers) | |
return total / len(numbers) |
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
import Injection | |
import Domain | |
protocol LoginInteractorInput { | |
func validate(email: String) | |
func validate(password: String) | |
func login(_ email: String, _ password: String) |
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
import Foundation | |
protocol LoginPresenterInput { | |
func emailDidChange(_ email: String) | |
func passwordDidChange(_ password: String) | |
func submit() | |
} |
NewerOlder