Guest User

Untitled

a guest
Nov 25th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. //We can define a namespace as follows:
  2. enum Namespace {
  3. static let fooConstant: String = "bar"
  4. }
  5.  
  6. //To use something inside the namespace we just have to write it like this:
  7. let foo: String = Namespace.fooConstant
  8. print(foo) // prints: "bar"
  9.  
  10. //Now to make use of this is a more usefull environment
  11. enum Request {
  12. enum Login {
  13. case with(_ user: User)
  14.  
  15. struct User {
  16. let username: String
  17. let password: String
  18. }
  19. }
  20. }
  21.  
  22. let user: Request.Login.User = .init(username: "SomeUsername", password: "TheStrongestPasswordEver")
  23. let request: Request.Login = .with(user)
Add Comment
Please, Sign In to add comment