Skip to content
This repository has been archived by the owner on Jul 2, 2018. It is now read-only.

How to get an instance of Money based on a string symbol? #70

Closed
aliasbody opened this issue Dec 13, 2016 · 2 comments
Closed

How to get an instance of Money based on a string symbol? #70

aliasbody opened this issue Dec 13, 2016 · 2 comments

Comments

@aliasbody
Copy link

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!

@danthorpe
Copy link
Owner

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.

@aliasbody
Copy link
Author

Thank you for this fast answer and excellent work on the library.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants