带有示例的 Scala Float self() 方法
self()方法用于返回已指定的相同值。
Method Definition: (Value).self
Return Type: It returns the same value which has been specified.
示例 #1:
// Scala program of Float self()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying self method
val result = (5.4).self
// Displays output
println(result)
}
}
输出:
5.4
示例 #2:
// Scala program of Float self()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying self method
val result = (5).self
// Displays output
println(result)
}
}
输出:
5