Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. ``` Kotlin
  2. //En Java
  3. public class Car {
  4. //propiedades omitidas para este ejemplo
  5.  
  6. public boolean isRecent(){
  7. return this.year >= 2015
  8. }
  9. }
  10.  
  11.  
  12. //En Kotlin
  13. class Car{
  14. //propiedades omitidas para este ejemplo
  15.  
  16. fun isRecent(): Boolean {
  17. return this.year >= 2015
  18. }
  19. }
  20. ```
  21.  
  22. O podemos usar mejor la forma de expresión:
  23.  
  24. ``` Kotlin
  25. //En Kotlin
  26. class Car{
  27. //propiedades omitidas para este ejemplo
  28.  
  29. fun isRecent() = this.year >= 2015
  30. }
  31. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement