This file contains hidden or 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 myVar: Int? = 42 | |
| let myUnwrappedVar = myVar! |
This file contains hidden or 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 {} | |
| class Dog: Animal {} |
This file contains hidden or 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 myVar: Int? = nil |
This file contains hidden or 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 condition = true | |
| if condition { | |
| print("True") | |
| } |
This file contains hidden or 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
| @State private var scale: CGFloat = 1 | |
| func animateScale() { | |
| scale = 2 | |
| // ¿Qué método va aquí? | |
| } |
This file contains hidden or 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 ParentView: View { | |
| @State private var myState: MyType | |
| var body: some View { | |
| ChildView(myState: $myState) | |
| } | |
| } | |
| // ¿Qué sintaxis va en ChildView? |
This file contains hidden or 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 MyViewModel: ObservableObject { | |
| @Published var myProperty: String? | |
| func updateProperty() { | |
| myProperty = "New Value" | |
| // ¿Qué método va aquí? | |
| } | |
| } |
This file contains hidden or 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 sumOfSquares(a: Int, b: Int) -> Int { | |
| return a * a + b * b | |
| } |
This file contains hidden or 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
| print(Int("42")) |
This file contains hidden or 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 filterNumbers(array: [Int], isEven: Bool) -> [Int] { | |
| return array.filter { isEven ? ($0 % 2 == 0) : ($0 % 2 != 0) } | |
| } | |
| let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
| let result = filterNumbers(array: numbers, isEven: true) |