https://kotlinlang.org logo
#android
Title
# android
p

pablisco

04/03/2019, 6:39 AM
Does this seem like a good use of extension functions? Yay or nay? Any suggestions? https://twitter.com/pablisc0/status/1113129390572032000
👍 3
r

rook

04/03/2019, 3:08 PM
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

pablisco

04/03/2019, 4:49 PM
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

galex

04/17/2019, 5:29 AM
Looks good to me