Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. public class User {
  2.  
  3. //one-to-one
  4. private Profile profile = new Profile(this);
  5.  
  6. }
  7.  
  8. public class Profile {
  9.  
  10. private User user;
  11.  
  12. public Profile(User user) {
  13. user.setProfile(this);
  14. this.user = user;
  15. }
  16.  
  17. }
  18.  
  19. class User(
  20.  
  21. var profile: Profile = Profile(this) //error, since `this` is not in that context
  22.  
  23. )
  24.  
  25. class Profile (
  26.  
  27. var user: User?
  28.  
  29. ) {
  30.  
  31. constructor(user: User): this(user)
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement