Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //We can define a namespace as follows:
- enum Namespace {
- static let fooConstant: String = "bar"
- }
- //To use something inside the namespace we just have to write it like this:
- let foo: String = Namespace.fooConstant
- print(foo) // prints: "bar"
- //Now to make use of this is a more usefull environment
- enum Request {
- enum Login {
- case with(_ user: User)
- struct User {
- let username: String
- let password: String
- }
- }
- }
- let user: Request.Login.User = .init(username: "SomeUsername", password: "TheStrongestPasswordEver")
- let request: Request.Login = .with(user)
Add Comment
Please, Sign In to add comment