mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
How to pass newly created object into a variable? #201
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Guferos on GitHub (Feb 7, 2018).
Hi,
It's more question than an issue. I want to create a new object and then immediately assign it into my class variable. This is how I've been doing that:
It works, however it feels like a lot of code. Is it a correct and only way of returning that object into the main context?
@JohnEstropia commented on GitHub (Feb 8, 2018):
Yes, this is correct (although the
successargument is not reallytransaction, it's thesessioninstance). It looks verbose because you are doing two things here:You'll see this better if you trim all the syntax stuff:
@iby commented on GitHub (Jan 11, 2019):
Glad I've found this! I think documentation would benefit from including this case as it seems pretty ordinary? Passing objects safely and Updating objects kind of imply that, but it's not apparent that the object must be fetched outside the transaction first to be simply accessed. 🤷♂️