Questions tagged [function-literal]

38 questions
1
vote
1 answer

Knockout - keyCode property not being passed through wrapped function

I've set up my Knockout bindings to have a keypress event because I wish to detect Enter on an input field. If I have the following: data-bind="event: { keypress: KeyPress }" and my view-model has this.KeyPress = function(data, event) { …
awj
  • 7,482
  • 10
  • 66
  • 120
0
votes
1 answer

How does the underscore placeholder in (println _) represent an entire parameter list of its original function literal?

I tried to make an example to explain that the placeholder _ without parentheses can represent (be expanded to) any number of parameters with any type, not just can represent "only one" parameter with any type. However, the one I made was incorrect…
Julia Chang
  • 181
  • 1
  • 8
0
votes
1 answer

Variable definition in Scala function literal

I'm wondering the result of the piece of code object localTest { def hello = { var t = 3 () => { t = t + 3 println(t) } } } object mainObj { def main(args: Array[String]): Unit = { val test = localTest.hello …
Jason_typ
  • 3
  • 1
0
votes
1 answer

Function as argument, access inner parameter

The package valyala/fasthttp implements the following function type: type RequestHandler func(ctx *RequestCtx) It is used in buaazp/fasthttprouter like this: func (r *Router) Handle(method, path string, handle fasthttp.RequestHandler) { …
Arnaud H
  • 881
  • 2
  • 10
  • 16
0
votes
1 answer

scala function literal confusion

I have made a unit test to study Scala function literal format and found it quite confusing, could you please help me understand meaning of different syntax? @Test def supplierLiteral: Unit = { object Taker { def…
Chen Fan
  • 1
  • 2
0
votes
1 answer

Receiving "missing parameter type" when using underscore for input parameter on function literal

I have a trait with generic parameters which contains a method where I am attempting to define the default implementation as "empty". trait MetaBase[T <: Throwable] { ... def riskWithEvent[V]( vToEvaluate: => V, failureTEvent:…
chaotic3quilibrium
  • 5,661
  • 8
  • 53
  • 86
0
votes
1 answer

Why is this function seen as a delegate?

In an attempt to wrap a C function taking callbacks, I encountered the problem of member functions being seen as delegates. The C function wouldn't take delegates, so I settled on something else instead: extern(C) void onMouse(void delegate(int,…
hpm
  • 1,202
  • 13
  • 34
0
votes
1 answer

AspectJ can't work on Scala function literal?

I have the following scala class and annotated aspectj class: package playasjectj import org.aspectj.lang.annotation.Pointcut import org.aspectj.lang.annotation.Aspect import org.aspectj.lang.annotation.Before class Entity { def…
Grant
  • 500
  • 1
  • 5
  • 18
1 2
3