Retourner au contenu associé (journal : Ada, langage et ressources)
Posté par Imagine2 le 24 juin 2013 à 17:20. En réponse au journal Ada, langage et ressources. Évalué à 1.
Est-ce ce qu'on appelle "extractor" en Scala? Voici par exemple, comment construire un objet de type "pair" à partir d'un entier:
object Twice { def apply(x: Int): Int = x * 2 def unapply(z: Int): Option[Int] = if (z%2 == 0) Some(z/2) else None }
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
[^] # Re: langage fonctionnel
Posté par Imagine2 . En réponse au journal Ada, langage et ressources. Évalué à 1.
Est-ce ce qu'on appelle "extractor" en Scala?
Voici par exemple, comment construire un objet de type "pair" à partir d'un entier: