Guest User

Untitled

a guest
Jul 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. fun main(args: Array<String>) {
  2. val str = "I am a string"
  3.  
  4. str.run {
  5. // no lambda params, receiver is value type (String), returns Unit.
  6. }
  7.  
  8. str.let {
  9. // lambda params are value type (String), no receiver, returns Unit.
  10. }
  11.  
  12. str.apply {
  13. // no lambda params, receiver is value type (String), returns value type (String).
  14. }
  15.  
  16. str.also {
  17. // lambda params are value type (String), no receiver, returns value type (String).
  18. }
  19.  
  20. with(str) {
  21. // no lambda params, receiver is value type (String), returns Unit,
  22. // it does NOT an extension function though the receiver will be defined as a parameter.
  23. }
  24. }
Add Comment
Please, Sign In to add comment