You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deftakeOnePointedGraph:Try[PointedGraph[Rdf]] = {
valit= nodes.iterator
if (!it.hasNext) {
Failure(WrongExpectation("expected exactly one node but got 0"))
} else {
valfirst= it.next
Success(PointedGraph(first, graph))
}
}
I wonder, why does it return try? In most of scala collection such thing is called heapOption and returns Option. I suggest that we change is in a same way.
The text was updated successfully, but these errors were encountered:
@antonkulaga Some collection methods return an Option (eg headOption, as you say), others throw exceptions (eg head). So takeOnePointedGraph returning Try is just a nicer way of having the exception. The reason why both head methods are needed so the client can decide if the value is optional or not.
@inthenow I simply do not like how method are named in PointedGraphs. There are conventions in scala collections, so head and headOption are short names that are obvious for the users. And actually verbose
deftakeOnePointedGraph
means that we take head (not an arbitary onePointedGraph)
@antonkulaga In RDF triples are not ordered. So this method will not necessarily return the same PG for each call. It partly depends on the underlying lib.
I see that takeOnePointedGraph
I wonder, why does it return try? In most of scala collection such thing is called heapOption and returns Option. I suggest that we change is in a same way.
The text was updated successfully, but these errors were encountered: