-
-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to export a map from a namespace? #2763
Comments
Does updating to the latest version have any effect? |
TestNamespaceOther is definitely bug. I will take a look. If you want to initialize a map, elegant solution is creating a class to wrapper map and do something in constructor. |
@CountBleck I updated to 0.27.13 and all of the things that I explained above executed the same. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Question
I have a set of data in key-value pairs that is constant, never changing. I need to access the values by using a variable that holds the key (it's dynamic). It is specific to a subset of code, and I'd like to put it in a namespace that relates to it. I figured that creating a Map was the best way to handle this type of data so I can access the values based off of the key (I've had other issues trying to access values on objects via dynamic keys in AssemblyScript otherwise I would use that). I figured exporting it from the namespace would provide me with what I've needed. I've exported functions from the same namespace without any issues. I am open to other options so if there's an AssemblyScript way to handle this please let me know.
The issue that I am having is that all of the code that I have tried exports an empty map, or doesn't compile. The only way to get it to work is to create a function that returns it, and export that function. I'd like to avoid doing this.
Here is some example code:
When in instantiate
TestClass
, the following shows up in the console:As you can see, the first three solutions all return an empty map.
I also have
TestNamespaceOther
in the code that doesn't even compile. When left uncommented, and I try to compile it, I get the following result:Somehow it cannot find the function declared immediately before it. I've tried other variations on this with no desired results as well.
The version of AssemblyScript that I am using is 0.25.2.
Any ideas how I can accomplish this? I am not sure if it's a bug or if this is an intended consequence of the way AssemblyScript works. As I've said, I'm open to other options, but being unable to use dynamic properties on objects I figured a map would be the way to go - but if there's a better way to model and access the data then I would gladly use that. just let me know.
The text was updated successfully, but these errors were encountered: