Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differents between single and singleOpt in Play framework and scala

In play framework the Anorm method using single and singleOpt. What is the difference between them?


1 Answers

As is often the case with methods suffixed with "opt", it means that it returns an Option. So the difference between those 2 methods is that singlewill treat the absence of result as an error, while singleOpt will just return None when there is no result (and the actual result wrapped in Some otherwise).

like image 112
Régis Jean-Gilles Avatar answered Jan 28 '26 21:01

Régis Jean-Gilles