##### ##
###### /###
/# / / ###
/ / / ### ##
/ / ## ##
## ## ## /### ## ### #### /## ### /###
## ## ## / ### / ## ### ### / / ### ###/ #### /
/### ## / / ###/ ## ### ###/ / ### ## ###/
We will be using the Nexus Software Repository for pushing our aars to maven-central, there are different methods to do this, another simple way is to upload to bintray and then push to maven-central from there, which one to use can completely depend upon the developer.
Nexus is a tool used by Sonatype to manage repositories. To use nexus, create an account and remember the user and password, this will be required in the automation script to deploy the artifacts.
Back in 2013 (2013, seriously!) Chris Banes wrote a blog post about an automation script he had written for pushing aars to maven, he had written this script for ActionBar-PullToRefresh (Again, this is 2013 we're talking about), this script can now be found on [github](https://github.
fun testLambdas(index: Int, myLambda: (index: Int) -> Unit){ | |
myLambda.invoke(index+1) | |
} | |
fun myBigLoop(){ | |
(0 .. 50).forEach { | |
// our lambda being consumed here. | |
testLambdas(it) { lambdaValue-> | |
println(lambdaValue) | |
} |
fun testLambdas(index: Int, myLambda: (index: Int) -> Unit){ | |
myLambda.invoke(index+1) | |
} | |
fun IntArray.myBigLoopWithClosure(salt: Double){ | |
forEach { | |
testLambdas(it) { myLambda -> | |
// the salt value over here is captured in a closure. | |
// thus, this will create a new instance of the lambda for every iteration | |
println(myLambda * salt) |
public static final void myBigLoopWithClosure(@NotNull int[] $this$myBigLoopWithClosure, double salt) { | |
Intrinsics.checkParameterIsNotNull($this$myBigLoopWithClosure, "$this$myBigLoopWithClosure"); | |
int $i$f$forEach = false; | |
int[] var5 = $this$myBigLoopWithClosure; | |
int var6 = $this$myBigLoopWithClosure.length; | |
for(int var7 = 0; var7 < var6; ++var7) { | |
// magical, isn't it! no new instance, nothing. | |
// the logical block is inlined here! | |
int element$iv = var5[var7]; |
inline fun <reified T> myGenericFunction(value: T): T { | |
// we can't do this without marking the parameter 'T' as reified and the function as inline. | |
val whoAmI = when (T::class.java.simpleName) { | |
Int::class.java.simpleName -> { | |
"I am an Int" | |
} | |
String::class.java.simpleName -> { | |
"I am Unknown" | |
} |
public static final void main() { | |
Object value$iv = "String"; | |
int value$iv = false; | |
String var3 = String.class.getSimpleName(); // the compiler adds it local here, thus making it persist post-compile. This value is then checked in the line below. | |
String whoAmI$iv = Intrinsics.areEqual(var3, Integer.TYPE.getSimpleName()) ? "I am an Int" : (Intrinsics.areEqual(var3, String.class.getSimpleName()) ? "I am Unknown" : "I am Groot!"); | |
boolean $i$f$myGenericFunction = false; | |
System.out.println(whoAmI$iv); | |
value$iv = true; | |
$i$f$myGenericFunction = false; | |
whoAmI$iv = Integer.class.getSimpleName(); // here as well. |
inline fun mixedLambdaHolder(crossinline nonLocalReturnBlockedLambda: () -> Unit, normalLambda: () -> Unit){ | |
nonLocalReturnBlockedLambda.invoke() | |
normalLambda.invoke() | |
} | |
fun main(){ | |
mixedLambdaHolder(nonLocalReturnBlockedLambda = { | |
return@mixedLambdaHolder // only this can be use, this only returns the lambda and not the main function | |
return // this throws a compiling error, saying 'return' is not allowed here. | |
}, normalLambda = { |
inline fun parameterPassedToOtherInlineFunction(lambda1: () -> Unit, noinline lambda2: () -> Boolean){ | |
// normal invoke, this is a normal lambda. | |
lambda1.invoke() | |
// passing the lambda to another function which doesn't inline this lambda | |
// will throw an error if lambda2 is not marked as noinline | |
someNonInlinedLambdaConsumingFunction(lambda2) | |
} | |
fun someNonInlinedLambdaConsumingFunction(lambda: () -> Boolean) : Boolean{ | |
return lambda.invoke() |
public static final void myBigLoop() { | |
byte var0 = 0; | |
Iterable $receiver$iv = (Iterable)(new IntRange(var0, 50)); | |
Iterator var1 = $receiver$iv.iterator(); | |
while(var1.hasNext()) { | |
int element$iv = ((IntIterator)var1).nextInt(); | |
int var4 = false; | |
// our function being called with a singleton instance of our Function1 implementated class | |
testLambdas(element$iv, (Function1)PresentationKt$myBigLoop$1$1.INSTANCE); // note the use of a singleton here |