次のコードでは、最初の式はResult内に "medical"、 "dental"または "pharmacy"のいずれかの文字列を含むResult [String]を返します。私は、文字列を取得するために、valステートメントの最後に.toOption.getを追加することができますが、結果を使用するより良い方法はありますか? .toOption.getがなければ、コードはコンパイルされません。知らずに言うのは難しいスカラ一致式でResult [String]を使用する方法
val service = element("h2").containingAnywhere("claim details").fullText().toOption
service match {
case Some("medical") => extractMedicalClaim
case Some("dental") => extractDentalClaim
case Some("pharmacy") => extractPharmacyClaim
case None => // handle the case where the result was empty
}
「Result」クラスはどこで定義されていますか?いくつかのフレームワークの一部ですか?私が知る限り、それは標準的なスカラクラスではなく、ドキュメントがなければ答えにくいです。 –