Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. fun <T1: Any, T2: Any, R: Any> lets(first: T1?, second: T2?, block: (T1, T2)-> R?): R? {
  2. return if (first != null && second != null) block(first, second) else null
  3. }
  4.  
  5. fun <T1: Any, T2: Any, T3: Any, R: Any> lets(first: T1?, second: T2?, third: T3?, block: (T1, T2, T3)-> R?): R? {
  6. return if (first != null && second != null && third != null) block(first, second, third) else null
  7. }
  8.  
  9. fun <T1: Any, T2: Any, T3: Any, T4: Any, R: Any> lets(first: T1?, second: T2?, third: T3?, fourth: T4?, block: (T1, T2, T3, T4)-> R?): R? {
  10. return if (first != null && second != null && third != null && fourth != null) block(first, second, third, fourth) else null
  11. }
  12.  
  13. lets(userLoginForm.email, userLoginForm.password) { email, password ->
  14. // email and password guaranteed to not be null
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement