Shawn
03/28/2018, 3:47 PMpolocode
is apparently something very different from polacode
lol)perryprog
03/28/2018, 3:48 PMperryprog
03/28/2018, 3:48 PMShawn
03/28/2018, 3:49 PMuser
03/28/2018, 3:57 PMhttps://kotlinlang.slack.com/files/U5KGFBE73/F9XG80YN7/code.png▾
user
03/28/2018, 3:58 PMhttps://kotlinlang.slack.com/files/U5KGFBE73/F9XG80YN7/code.png▾
valerie.turlington
03/28/2018, 5:19 PMfun getYear(): String? {
for (node in childNodes) {
val matcher = yearPattern.matcher(node.attr("href").trim())
if (matcher.find()) {
return matcher.group("year")
}
}
return null
}
Is there a more concise way to do this via collection functions?valerie.turlington
03/28/2018, 5:21 PMvalerie.turlington
03/28/2018, 5:21 PMShawn
03/28/2018, 5:21 PMvalerie.turlington
03/28/2018, 5:21 PMRuckus
03/28/2018, 5:22 PMchildren.firstOrNull { ... }
?valerie.turlington
03/28/2018, 5:22 PMRuckus
03/28/2018, 5:23 PMkristofdho
03/28/2018, 5:27 PMchildNodes.toSequence()
.map {
yearPattern.matcher(it.attr("href").trim())
}.firstOrNull {
it.find()
}?.group("year")
valerie.turlington
03/28/2018, 5:29 PMkristofdho
03/28/2018, 5:29 PMvalerie.turlington
03/28/2018, 5:29 PMvalerie.turlington
03/28/2018, 5:29 PMShawn
03/28/2018, 5:29 PMvalerie.turlington
03/28/2018, 5:29 PMvalerie.turlington
03/28/2018, 5:29 PMkristofdho
03/28/2018, 5:30 PMfirst
conditionRuckus
03/28/2018, 5:30 PMasSequence
)kristofdho
03/28/2018, 5:30 PMvalerie.turlington
03/28/2018, 5:31 PMvalerie.turlington
03/28/2018, 5:31 PMfred.deschenes
03/28/2018, 5:32 PMvalerie.turlington
03/28/2018, 5:32 PMziggy42
03/28/2018, 5:53 PMfind
here while still catching the exception?