Reified generics in Scala 2.10

Your argument is flawed. Kotlin has not been released yet*, and Ceylon just had its first version released, and I’ll quote one of the things it is missing from their announcement: reified generics So, excuse me, but what implementation proves it is possible? In fact, I haven’t looked much at what Kotlin is promising, but … Read more

How to get actual type arguments of a reified generic parameter in Kotlin?

Due to type erasure, actual generic arguments cannot be obtained through T::class token of a generic class. Different objects of a class must have the same class token, that’s why it cannot contain actual generic arguments. Edit: Since Kotlin 1.3.50, following the technique described below to get type information for a reified type parameter is … Read more

Comparing generic struct types

Edit: Sorry for the premature answer, it actually doesn’t work, because the compiler will choose the function for different types when called from within another function: func foobar<T,U> (lhs: Foo<T>, rhs: Foo<U>) -> Bool { return lhs.sameType(rhs) } If you stay in pure Swift territory, the following will work: Given a simple generic struct struct … Read more

Any way to inherit from same generic interface twice (with separate types) in Kotlin?

Yes, you’re missing an important detail of generics implementation on JVM: the type erasure. In a nutshell, the compiled bytecode of classes doesn’t actually contain any information about generic types (except for some metadata about the fact that a class or a method is generic). All the type checking happens at compile time, and after … Read more

How do I return a Filter iterator from a function?

Rust 1.26 fn filter_one(input: &[u8]) -> impl Iterator<Item = &u8> { input.iter().filter(|&&x| x == 1) } fn main() { let nums = vec![1, 2, 3, 1, 2, 3]; let other: Vec<_> = filter_one(&nums).collect(); println!(“{:?}”, other); } Rust 1.0 fn filter_one<‘a>(input: &’a [u8]) -> Box<Iterator<Item = &’a u8> + ‘a> { Box::new(input.iter().filter(|&&x| x == 1)) } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)