You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to capture the literal floating-point number that a person used in a data structure:
scala> trait Capture { def text: String }
defined trait Capture
scala> implicit class DoubleCapture(source: sourcecode.Text[Double]) extends Capture { def text = source.source }
defined class DoubleCapture
^
scala> val x: Capture = 5.0
<console>:49: error: type mismatch;
found : Double(5.0)
required: Capture
val x: Capture = 5.0
If DoubleCapture takes a Double, this works fine. But I don't want the Double itself, what I really want is the string representation from the code itself. I was hoping I could use sourcecode.Text to do this, but it doesn't seem to work.
The text was updated successfully, but these errors were encountered:
I'm trying to capture the literal floating-point number that a person used in a data structure:
If
DoubleCapture
takes aDouble
, this works fine. But I don't want theDouble
itself, what I really want is the string representation from the code itself. I was hoping I could usesourcecode.Text
to do this, but it doesn't seem to work.The text was updated successfully, but these errors were encountered: