Closed acardona closed 5 years ago
Looks fine to me.
I'm not familiar with the context here, but would it make sense to make
VarargsFunction.wrapMap()
actual vararg, i.e., take Object... obs
instead of Object[] obs
?
Thanks for looking at the code changes.
The VarargsFunction.wrapMap()
has to take an Object[]
, because it is invoked by ABinaryFunction
which itself takes a varargs, which within the code block appears as an Object[]
. Otherwise, it would be passing an Object[][]. So all is fine as is, and works correctly, which is the most important.
👍
The
VarargsFunction.wrapMap()
has to take anObject[]
, because it is invoked byABinaryFunction
which itself takes a varargs, which within the code block appears as anObject[]
. Otherwise, it would be passing an Object[][]. So all is fine as is, and works correctly, which is the most important.
Hmm, actually, did you try that???
private static void ao( final Object... i ) {
System.out.println( Arrays.toString( i ) );
}
private static void bo( final Object... i ) {
ao( i );
}
public static void main( final String[] args ) {
ao( "x", 1, 2 );
bo( "x", 1, 2 );
}
prints
[x, 1, 2]
[x, 1, 2]
So it looks like Object...
varargs will not be re-wrapped as Object[][]
Good to know! I was for some reason convinced that's not the case.
I have some features pending for ImgMath, will test and address the varargs in the next PR.
On Nov 16, 2018, at 7:11 AM, tpietzsch notifications@github.com wrote:
The VarargsFunction.wrapMap() has to take an Object[], because it is invoked by ABinaryFunction which itself takes a varargs, which within the code block appears as an Object[]. Otherwise, it would be passing an Object[][]. So all is fine as is, and works correctly, which is the most important.
Hmm, actually, did you try that???
private static void ao( final Object... i ) { System.out.println( Arrays.toString( i ) ); }
private static void bo( final Object... i ) { ao( i ); }
public static void main( final String[] args ) { ao( "x", 1, 2 ); bo( "x", 1, 2 ); } prints
[x, 1, 2] [x, 1, 2] So it looks like Object... varargs will not be re-wrapped as Object[][]
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Two fixes for ImgMath: