This commit is contained in:
cdle
2023-06-10 15:24:36 +08:00
parent aa1d74da4e
commit e985e9db8b
2 changed files with 46 additions and 2 deletions
+43
View File
@@ -307,6 +307,49 @@ func (sender *Strings) Longest(args ...interface{}) string {
longest = s.(string)
}
}
case [][]string:
for _, s := range v {
longest = sender.Longest(s)
}
case [][]interface{}:
for _, s := range v {
longest = sender.Longest(s)
}
}
}
return longest
}
func (sender *Strings) Shortest(args ...interface{}) string {
var longest string
for _, arg := range args {
switch v := arg.(type) {
case string:
if len(v) < len(longest) {
longest = v
}
case []string:
for _, s := range v {
if len(s) < len(longest) {
longest = s
}
}
case []interface{}:
for _, s := range v {
if len(s.(string)) < len(longest) {
longest = s.(string)
}
}
case [][]string:
for _, s := range v {
longest = sender.Shortest(s)
}
case [][]interface{}:
for _, s := range v {
longest = sender.Shortest(s)
}
}
}
return longest