codeslubber
05/31/2017, 7:31 PMjavaru
05/31/2017, 8:12 PMpublic static void assertAll(String heading, Executable... executables)
// "Executable" is an interface with a single "execute()" method
// JAVA
assertAll("test the 'add' method",
() -> assertEquals(4, calculator.add(2, 2)),
() -> assertEquals(5, calculator.add(2, 3))
);
// KOTLIN
# the 'assertEquals' is underscored with error "None of the following functions can be called with the arguments supplied."
assertAll("test the 'add' method",
{ assertEquals(4, calculator.add(2, 2)) },
{ assertEquals(5, calculator.add(2, 3)) }
)
marcoferrer
05/31/2017, 8:40 PMT::class.constructors.find {
it.parameters.size == 1 &&
it.parameters[0].type.isSubtypeOf(Item::class.createType())
}
T::class.constructors.find {
it.parameters.size == 1 &&
it.parameters[0].type.jvmErasure.isSubclassOf(Item::class)
}
trevjones
06/01/2017, 4:05 AMgyl
06/01/2017, 7:59 AMoutlying
06/01/2017, 9:21 AMn
arguments. Is there a way to generate proper builder for Java? Some sort of annotation like @JvmOverloads
myanmarking
06/01/2017, 9:21 AMnhaarman
06/01/2017, 4:51 PMval container: Container
var property: Int
set(value) {
container.property = value
}
get() {
container.property
}
I was thinking about something like this, but that doesn't work obviously
val container: Container
var property: Int by container.property
user
06/01/2017, 9:11 PMpaisrikanth
06/02/2017, 6:34 AMmenegatti
06/02/2017, 11:13 AMkingsley
06/02/2017, 11:24 AMapatrida
06/02/2017, 2:30 PMkingsley
06/02/2017, 2:30 PMUnsuportedOperationException
nyxcode
06/02/2017, 3:57 PMnyxcode
06/02/2017, 5:47 PMbj0
06/02/2017, 6:13 PMval arrayCopy = ...
?nulldev
06/02/2017, 10:04 PMJSON -> Kotlin JS Object
de-serialization framework and since nobody seems to know of one, I plan to write one myself.
Unfortunately, my job is severely hampered by the lack of reflection in Kotlin JS. I just want to know whether or not I should wait for reflection before I start or if I should just start but put in some hacky workarounds instead of using reflection.chi
06/03/2017, 4:51 AMwouterdoeland
06/03/2017, 8:30 AM"
to "
, is there a fix for that?andrewoma
06/04/2017, 6:55 AMvaskir
06/04/2017, 7:17 AM.map(parser.parse)
instead of .map { parser.parse(it) }
?ziad
06/04/2017, 4:11 PMchb0kotlin
06/04/2017, 7:20 PMclass Test(val thing:String, val other:Int)
public class Authority implements GrantedAuthority {
private User user;
private String role;
public Authority(User user, String role) {
this.user = user;
this.role = role;
}
}
test code:
public class Foo {
public static void main(String[] args) {
Arrays.stream(Test.class.getDeclaredConstructors()).map(Constructor::getParameters)
.flatMap(Arrays::stream).map(Parameter::getName).forEach(System.out::println);
Arrays.stream(Authority.class.getDeclaredConstructors()).map(Constructor::getParameters)
.flatMap(Arrays::stream).map(Parameter::getName).forEach(System.out::println);
}
}
output:
arg0
arg1
user
role
if you compile the java code with -parameters
you get the bottom 2 lines with java. Without it, you get the same as the 2 kotlin lineskingsley
06/04/2017, 7:40 PMVerifyError
open class Base(val me: String) {
companion object : Base(string()) {
private fun string() = "companion object"
}
}
blakelee
06/05/2017, 2:27 AMAn annotation parameter must be a class literal (T::class)
I want to do something like myclass<myType>::class.java
It's looking like I'm going to have to define a class for each of my types 😞redrield
06/05/2017, 2:39 AMoperator fun shl(other: Foo): Foo { }
could work on val foo = Foo(); foo << Foo()
adolev
06/05/2017, 9:25 AMandyr
06/05/2017, 9:52 AMcy
06/05/2017, 12:10 PM