Skip to content

Commit

Permalink
Invocations is a nice to have but I don't see where to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
cprieto committed Oct 25, 2015
1 parent 7153662 commit 1a5809b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/ii_conventions/_17_Invoke_.kt
Expand Up @@ -30,7 +30,17 @@ fun testTypeWithInvokeExtension() {
1() //huh?..
}

class Invokable
class Invokable {
private var number = 0
operator fun invoke() : Invokable {
number += 1
return this
}

fun getNumberOfInvocations() : Int {
return number
}
}

fun todoTask17(): Nothing = TODO(
"""
Expand All @@ -41,6 +51,5 @@ fun todoTask17(): Nothing = TODO(
references = { invokable: Invokable -> })

fun task17(invokable: Invokable): Int {
todoTask17()
// return invokable()()()().getNumberOfInvocations()
return invokable()()()().getNumberOfInvocations()
}
2 changes: 1 addition & 1 deletion test/ii_conventions/_17_Invoke.kt
@@ -1,6 +1,6 @@
package ii_conventions

import junit.framework.Assert
import org.junit.Assert
import org.junit.Test as test

class _17_Invoke {
Expand Down

0 comments on commit 1a5809b

Please sign in to comment.