Created
May 29, 2011 04:24
-
-
Save kijuky/997463 to your computer and use it in GitHub Desktop.
[致命的]Amountでのイレイジャ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GrabResolver(name='jsciencerepos', root='http://maven.obiba.org/maven2/') | |
@Grab('org.jscience:jscience:4.3.1') | |
import javax.measure.quantity.* | |
import org.jscience.physics.amount.Amount | |
a = Amount.valueOf("1 m") | |
b = Amount.valueOf("1 m") | |
Amount<Mass> c = (a + b).to(Length.UNIT) // 正しくは Amount<Length> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> import javax.measure.quantity._ | |
import javax.measure.quantity._ | |
scala> import org.jscience.physics.amount.Amount | |
import org.jscience.physics.amount.Amount | |
scala> val a = Amount.valueOf("1 m") | |
a: org.jscience.physics.amount.Amount[_] = 1 m | |
scala> val b = Amount.valueOf("1 m") | |
b: org.jscience.physics.amount.Amount[_] = 1 m | |
scala> val c: Amount[Mass] = (a plus b) to Length.UNIT | |
<console>:11: error: type mismatch; | |
found : javax.measure.unit.Unit[javax.measure.quantity.Length] | |
required: javax.measure.unit.Unit[javax.measure.quantity.Mass] | |
val c: Amount[Mass] = (a plus b) to Length.UNIT | |
^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment