martes, 10 de noviembre de 2015

My first post on Kotlin

As always...I was looking for another programming language to learn...I was thinking about Scala or Rust...but then I got this comment on Twitter -;)


So sure...why not Kotlin? -:)

So what's Kotlin all about? Well...Kotlin is a Statically typed programming language for the JVM, Android and the browser. It's also 100% interoperable with Java.

While this is not a mind bending language...meaning that you can get used to it pretty fast...it has some nice and cool feature that are worthy to explore...

As always...being this my first post...here's the Fibonacci list example...

fibonacci.kt
package Fibonacci

fun fib(num: Int, a: Int, b: Int): String {
 var result: String = ""
 if(a > 0 && num > 1) {
  result = result + (a+b) + " " + fib(num-1,a+b,a)
 }else if (a == 0) {
  result = a.toString() + " " + b + " " + (a+b) + " " + fib(num-1,a+b,b)
 }
 return result
}

fun main(args: Array<String>) {
 if (args.size == 0) {
      println("Please provide a number...")
      return
    }
   val num: Int = args[0].toInt()
   println(fib(num,0,1))
}

And the screenshot for sure -:)


Will post the LED_Numbers app really soon...so stay tuned -;)

Greetings,

Blag.
Development Culture.

No hay comentarios: