Created
April 2, 2024 08:43
-
-
Save amosgyamfi/78dfe0aa3dbdc2c4d3e806d492f3fef0 to your computer and use it in GitHub Desktop.
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
// | |
// LetVarDeclaration.swift | |
// SwiftInfo | |
// | |
// Created by Amos Gyamfi on 1.4.2024. | |
// | |
import SwiftUI | |
struct LetVarDeclaration: View { | |
let environment = "development" | |
@State var maxLogin: Int | |
// declare multiple constants or multiple variables on a single line, separated by commas | |
var x = 0.2, y = 0.3, z = 0.4 | |
var body: some View { | |
VStack { | |
Text("The login attemt is: \(maxLogin)") | |
Button { | |
if environment == "development" { | |
maxLogin = 100 | |
} else { | |
maxLogin = 10 | |
} | |
} label: { | |
Text("Login") | |
} | |
Divider() | |
HStack { | |
Text("x: \(x), ") | |
Text("y: \(y), ") | |
Text("z: \(z)") | |
} | |
} | |
.padding() | |
} | |
} | |
#Preview { | |
LetVarDeclaration(maxLogin: 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment