JoaquinJimenezGarcia / ListViewDemo

Example of a ListView for Android written in Kotlin
0 stars 0 forks source link

Pro tip #1

Open MeLlamoPablo opened 6 years ago

MeLlamoPablo commented 6 years ago
-private class MyCustomAdapter(context: Context) : BaseAdapter() {
+private class MyCustomAdapter(private val mContext: Context) : BaseAdapter() {
-       private val mContext: Context
        private val names = arrayListOf<String>(
                "Joaquín Jiménez", "Marta Flores", "Guillermo González"
        )

-       init {
-           this.mContext = context
-       }
JoaquinJimenezGarcia commented 6 years ago

Gracias, tío! Lo acabo de ver. Pero, ¿cuál es la diferencia exactamente?

MeLlamoPablo commented 6 years ago

Ninguna, es un azúcar sintáctico que te permite definir propiedades sin tener que declararlas y después asignarlas en el init.