Guest User

Untitled

a guest
May 8th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // Three parameters are repeated in both functions
  2.  
  3. func login(username: String, password: String, isExpired: Bool) {
  4. // ...
  5. }
  6.  
  7. func authenticate(username: String, password: String, isExpired: Bool) {
  8. // ...
  9. }
  10.  
  11. // Solution: Group them as a separated type
  12.  
  13. struct Required {
  14. let username: String
  15. let password: String
  16. let isExpired: Bool
  17. }
  18.  
  19. func login(required: Required) {
  20. // ...
  21. }
  22.  
  23. func authenticate(required: Required) {
  24. // ...
  25. }
Add Comment
Please, Sign In to add comment