How to get an instance of Money based on a string symbol?
aliasbody opened this issue · comments
Hi everyone,
Here what I'm trying to do, please let me know if my way of thinking if the mistake here.
I received a symbol (EUR, CHF, USD...) as a string from a fermer, and I have it associated with my store's object (in a way that this defines what currency the stores accepts).
My idea here was to simply create a currency variable, from Money, on the store's object and then call if every time I would bee some conversion/presentation to be done.
So it would be like this:
print("You have to pay \(StoreObject.currency(100))")
Can I do this using the actual Money library or is there any other way to do that?
Thank you!
Hi @aliasbody - yeah, this isn't possible, and it's a long standing issue, #29.
Essentially, Money is a framework of static currency/money types, and you require dynamic money types, to create them from strings.
This is definitely something that I would like to change in a future version of this framework, but at the moment, I don't have enough time to work on it.
I would say that you should look into other options as solutions to this problem.
I'm gonna close this as a duplicate of #29.
Thank you for this fast answer and excellent work on the library.