Does this seem like a good use of extension functi...
# android
p
Does this seem like a good use of extension functions? Yay or nay? Any suggestions? https://twitter.com/pablisc0/status/1113129390572032000
đź‘Ť 3
r
You can replace most of this case with
QuantityString
by itself. Unless you want to arbitrarily differentiate between
Some
and
Many
. I’m assuming you have some threshold somewhere that decides whether to make a
Some
or
Many
.
p
Shouldn’t really use
QuantityString
for those cases… From the documentation:
The selection of which string to use is made solely based on grammatical necessity. In English, a string for zero will be ignored even if the quantity is 0, because 0 isn’t grammatically different from 2, or any other number except 1 (“zero books”, “one book”, “two books”, and so on).
https://developer.android.com/guide/topics/resources/string-resource.html#Plurals It may work for some, but not for all languages
In this situation I’m thinking that the three cases would be something like:
Copy code
None -> "Nothing yet."
Some(100) -> "Counted 100 times."
Many -> "Counted too many times."
g
Looks good to me