Timeline for Default Object Property
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 5, 2018 at 2:24 | history | edited | Eddie D | CC BY-SA 4.0 |
deleted 6 characters in body
|
Jun 5, 2018 at 2:24 | vote | accept | xon52 | ||
Jun 5, 2018 at 2:24 | comment | added | xon52 | @EddieDelRio great idea. I am getting an error in my code that add is not a function of posts, but as yours clearly works, I think this is answered and the issue is in my code. | |
Jun 5, 2018 at 2:08 | comment | added | Eddie D | Lemme know if that works. Kind of a hack, but it'll do the job ;D | |
Jun 5, 2018 at 2:06 | history | edited | Eddie D | CC BY-SA 4.0 |
added 596 characters in body
|
Jun 5, 2018 at 2:06 | comment | added | Eddie D | Figured out a way to do it by extending the Array class. | |
Jun 5, 2018 at 2:05 | comment | added | xon52 |
@EddieDelRio return this._posts returns an empty object rather than items. Not to mention my goal of being able to have [instance].posts.add() wouldn't be achieved...
|
|
Jun 5, 2018 at 1:59 | history | edited | Eddie D | CC BY-SA 4.0 |
deleted 6 characters in body
|
Jun 5, 2018 at 1:56 | comment | added | xon52 | No, not static. The array is instance dependent. | |
Jun 5, 2018 at 1:53 | comment | added | Isaac | sounded like static variable? stackoverflow.com/questions/1535631/… | |
Jun 5, 2018 at 1:49 | comment | added | Eddie D | So you want the same value no matter what instance of the class right? There's a way to do that. | |
Jun 5, 2018 at 1:48 | comment | added | xon52 |
It's not so much about hiding the array, more about getting those add/remove functions out of the class's context and into the variable context... Not sure what the terms are. Instead of MyClass.addPost I want to know if I can have MyClass.post.add() while still being able to have a default value returned for MyClass.post I am beginning to think it's not possible, but thought I'd ask.
|
|
Jun 5, 2018 at 1:35 | history | answered | Eddie D | CC BY-SA 4.0 |