Considering
object A {
def m(i: Int) = i
val m = (i: Int) => i * 2
}
one gets
scala> A.m(2)
<console>: error: ambiguous reference to overloaded definition,
both value m in object A of type => (Int) => Int
and method m in object A of type (i: Int)Int
match argument types (Int)
A.m(2)
^
Accessing the val
can be done with
scala> val fun = A.m
fun: (Int) => Int = <function1>
scala> fun(2)
res: Int = 4
or
scala> A.m.apply(2)
res: Int = 4
but how would one access the def
?
In Physics, force is defined as: The push or pull on an object with mass causes it to change its velocity. Force is an external agent capable of changing a body's state of rest or motion. It has a magnitude and a direction.
transitive verb. If someone forces you to do something, they make you do it even though you do not want to, for example, by threatening you.
Therefore, F= m * a, F = ^P/^t, and F = ^(mV)/^t are formulae for force from Newton's first and second laws.
fundamental force, also called fundamental interaction, in physics, any of the four basic forces—gravitational, electromagnetic, strong, and weak—that govern how objects or particles interact and how certain particles decay. All the known forces of nature can be traced to these fundamental forces.
It is total rubbish (please, don't do this at home), but you can do it by assigning A
to a variable of structural type, that has only the first m
.
val x : { def m(i:Int):Int } = A
x.m(10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With