Skip to content

Instantly share code, notes, and snippets.

@kijuky
Created May 29, 2011 04:24
Show Gist options
  • Save kijuky/997463 to your computer and use it in GitHub Desktop.
Save kijuky/997463 to your computer and use it in GitHub Desktop.
[致命的]Amountでのイレイジャ
@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>
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