Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created April 2, 2024 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosgyamfi/78dfe0aa3dbdc2c4d3e806d492f3fef0 to your computer and use it in GitHub Desktop.
Save amosgyamfi/78dfe0aa3dbdc2c4d3e806d492f3fef0 to your computer and use it in GitHub Desktop.
//
// 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