Compose function with data object method
I am trying to compose a function with a data object's method.
I have a list that I want to map to another type (Id).
case class Href(val value: String) {
def toId(): Id = {
return null //null for clarity
}
}
def toHref(element: WebElement): Href = {
return Href(element.getAttribute("href"));
}
seq.map(toHref _ andThen ((href:Href)=>href.toId))
toHref just maps a WeElement to a Href. I would like to compose the
function toHref with the member function Href.toId. Is there a shorter
cleaner way to express this?
No comments:
Post a Comment