What do you think about using default values to en...
# android
d
What do you think about using default values to enable API users define vertical/horizontal dimensions but also specific sides?
Copy code
fun withMargins(
    @Px horizontal: Int = 0,
    @Px vertical: Int = 0,
    @Px start: Int = horizontal,
    @Px top: Int = vertical,
    @Px end: Int = horizontal,
    @Px bottom: Int = vertical
) {
 // Operation   
}
it seems like an abuse but it is convenient for the reader
b
I'd probably separate the method to support horizontal/vertical from explicit s, t, e, b
1
Then your horizontal/vertical method can just feed into the other values for s, t, e, b
d
I was thinking about supporting
horizontal = X, top = Y
, but I would need to see how often that happens
I like about your approach which is stricter and facilities the usage of symmetric dimensions
👍 1
b
Yep and if they want unsymmetrical dimensions you have the finer grained option available to them
m
You could also add another function which takes an
all: Int
argument.
👍 1