-
Notifications
You must be signed in to change notification settings - Fork 53
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
Make return type to dictionary for discoverability of vault types #127
Conversation
what is the motivation here ? @satyamakgec |
Dictionaries are more usable than arrays because you can index into them without having to iterate through the array to find an id, and you can still get an array from them anyway if you want by using |
But in this context it is only used for if item exists, which is getSupportedVaultTypes().Contains(t) vs getSupportedVaultTypes()[t]!=nil or even if let exists = getSupportedVaultTypes(t){
if exists {
}
} somehow I feel it doesn't make sense here. It would have some saving if it is very big dictionary maybe, but here I think readability is better trade off. |
|
yeah but it matters only for big N; here we have something like N<10 maybe on worst case ( on most cases N=1 ) ( even iterating can be cheaper for some N < x ) But I think in the end, readability vs cost tradeoff in a way. PS: actually as the current state of Cadence, I think this makes sense ( with broken contracts etc ) but i believe Cadence should fix that |
but it would matter for something like the NFT standard, and I want to make the function signatures as similar as possible for these kinds of methods so using them can be similar. We're going to add something like this for NFTs also |
Extension to #123