The purpose of this trait is to be able to represent quantities -- things that have some ordered (and/or numerical) value -- (or sequences of quantities) in a more meaningful way than simply using "Any".
For values that you want to consider as numeric, then use asFractional. Valuable is very similar to Numeric/Fractional but has additional methods, in particular fromString, and these methods typically result in a Try[X] as opposed to X.
For more detail, see Scalar
You can also represent sequences by Value (in particular, SequenceValue). Such values will yield Some(sequence) when asSequence is invoked. Other types of Value will yield None in this situation.
In the vast majority of cases, you can simply provide a String as the input to Value.apply. This is the normal mechanism when you are reading values from HTML, JSON, Config, whatever. Values that derive from String representations are normally StringValues These typically result in an appropriate value when asValuable is invoked, that's to say -- not the String value but the parsed numeric (Valuable) value. If you have a String that you want only to be considered a String, then use QuotedStringValue
Method to show this Scalar simply, obviously and elegantly. Typically, this tries to appear like the source. If you're interested in the Scalar wrapper type, use toString.
Method to show this Scalar simply, obviously and elegantly. Typically, this tries to appear like the source. If you're interested in the Scalar wrapper type, use toString.
Value parameters
format
Used to format the underlying value. If it is null, then we use the source. We are using call-by-name because we don't want this evaluated eagerly since the result of the defaultFormat might change.
Attributes
Returns
a String representing the value which, typically, does not include the wrapper type.