Kotlin Native 1.0 was quietly released today. No announcement, no blog post. I thought v1.0 would be a bigger deal and would have some announcement.
Friday, October 12, 2018
Thursday, October 4, 2018
Why Kotlin does not use new keyword when creating a new instance?
The answer is
1) Kotlin functions are first-class
2) A constructor is a function that can be assigned to a property of a function type, passed as an argument to a higher-order function or returned by a higher-order function.
class Foo
val foo : () -> Foo = ::Foo
val a : Foo = foo() // Creating a Foo through a property
val b : Foo = Foo() // Creating a Foo directly by calling a
// constructor
val c : Foo = new Foo() // <-- Incorrect syntax that clearly shows
// that "new" keyword has no place in
// a language where functions
// are first-class
1) Kotlin functions are first-class
2) A constructor is a function that can be assigned to a property of a function type, passed as an argument to a higher-order function or returned by a higher-order function.
class Foo
val foo : () -> Foo = ::Foo
val a : Foo = foo() // Creating a Foo through a property
val b : Foo = Foo() // Creating a Foo directly by calling a
// constructor
val c : Foo = new Foo() // <-- Incorrect syntax that clearly shows
// that "new" keyword has no place in
// a language where functions
// are first-class
Wednesday, February 14, 2018
How to get a list of file names from gradle runtime dependencies
If you need a list of file names from runtime (or other type of) dependencies, this is one way to do it:
def files = []
configurations.runtime.files.forEach() { f ->
files += f.name
}
The list can be helpful if you need to put it as a Class-Path attribute of JAR manifest file:
jar {
manifest {
def files = []
configurations.runtime.files.forEach() { f ->
files += f.name
}
attributes("Class-Path": files.join(' '))
}
}
def files = []
configurations.runtime.files.forEach() { f ->
files += f.name
}
The list can be helpful if you need to put it as a Class-Path attribute of JAR manifest file:
jar {
manifest {
def files = []
configurations.runtime.files.forEach() { f ->
files += f.name
}
attributes("Class-Path": files.join(' '))
}
}
Subscribe to:
Posts (Atom)