Inexplicable watchOS 2 Error - syntax-error

So I have my watch app asking for text input as is below but it gets this error that makes NO sense!
I was hoping someone could help me out with this? Thanks in advance!

This is the definition according to the documentation:
func presentTextInputControllerWithSuggestions(_ suggestions: [String]?,
allowedInputMode inputMode: WKTextInputMode,
completion completion: ([AnyObject]?) -> Void)
The problem seems to be in your last parameter which is String -> Void. You get there [AnyObject]? not String.

Related

Someone please explain what is the use of now and how it is working here

I am new to Vue.js and have some understanding how watch works here. Can someone please explain how now function is working here. Thanks in Advance. your help is much appreciated.
watch:{
now: function(newNow){
this.someTimeInSec = // methodcall to return the time in sec
}
}
when we want to react to any data changes, in this case "now", we can define methods against that data variable in the watch property.
Two values newValue, oldValue will be passed to this function and you can update other properties/UI accordingly.
This is well documented in the official docs

compile error related to "in expansion of macro ‘CHKERRQ"’

I have this compiler error related to "in expansion of macro ‘CHKERRQ’" from PETSC whenever I call "CHKERRQ", I am not sure what causes it, could anyone please give any advice?
Thanks for your help in advance,
Feng
I solved the problem in the end. The return type of my function is void. I need to set the return type of my function, which calls lots of PETSC routines, to PetscErrorCode.

Suspend a Erlang process by using receive after infinity timeout

I'm new to Erlang and I want to suspend in a function. I use receive with infinity timeout, my function looks like:
suspend() ->
receive
after
infinity->ok
end.
When I ran dialyzer tool, it return "Function has no local return". Should I replace this function with timer:sleep(infinity). For suspend, which one is better? Thank you so much.
The function timer:sleep/1 is defined as:
sleep(T) ->
receive
after T -> ok
end.
which is essentially the same as your suspend/0 function, so either approach would work. I'd advise using timer:sleep/1, though, as it's already defined for you, and anyone reading it will instantly know what it is and what it does.

Velocity template function from string literal

Is it possible to call a function that was created from string literal? For example
${object}.staticPartOfFunctionName${dynamicPartOfFunctionName}()
doesn't return correct value, but instead just prints the object and the function name.
$object.staticFunctionName()
prints correctly, and
$object.staticPartOfFunctionName${dynamicPartOfFunctionName}()
gives warning "Encountered ")"
You don't have to use introspection:
#evaluate("\$object.staticPartOfFunctionName${dynamicPartOfFunctionName}()")
Well, I found one solution myself from Java side:
$object.getClass().getMethod("staticPartOfFunctionName$dynamicPartOfFunctionName").invoke($object))
I don't know if it's any good, so if someone knows how to do it velocity way, lemme know.

Usage of CompletableFuture's exceptionally method in Kotlin

I'm trying to handle CompletableFuture exceptions in Kotlin, but I'm not able to figure out how to supply the appropriate parameters. So, for example, I have:
CompletableFuture.runAsync { "sr" }
.exceptionally{e -> {}}
but then the compiler complains Cannot infer type parameter T.
How do I fix this?
Quite a tricky case which becomes tricky because of some Kotlin magic :)
The direct solution to your problem would be the following code:
CompletableFuture.runAsync {"sr"}
.exceptionally({e -> null})
The detailed explanation goes here:
The runAsync method accepts a Runnable which means after execution it will return Void. The function passed to exceptionally method must match the generic parameter of the CompletableFuture so in this particular case, you need to help a compiler by returning null explicitly.
So the following will compile without problems:
CompletableFuture.runAsync {"sr"}
.exceptionally({null})
CompletableFuture.runAsync {}
.exceptionally({null})
In the first case, the "sr" String will simply be ignored and not returned since the runAsync accepts a Runnable.
You probably wanted to do something like:
CompletableFuture.supplyAsync {"sr"}
.exceptionally({"sr_exceptional"})
or:
CompletableFuture.supplyAsync {"sr"}
.exceptionally({e -> "sr_exceptional"})