title: Kotlin Lambda function as a parameter
body: <p>I am new to Kotlin and have difficulty understand the code below</p>
  <pre><code>private fun &lt;T&gt; catchAsyncExceptions(f: () -&gt; CompletableFuture&lt;T&gt;) =
      try {
          f().get()
      } catch (e: ExecutionException) {
          throw e.cause!!
      }
  </code></pre>
  <p>So this function is called <code>catchAsyncExceptions</code>, its input parameter is a function called <code>f</code> which is <code>() -&gt; CompletableFuture&lt;T&gt;</code>
  So I would think that you use it by</p>
  <pre><code>catchAsyncExceptions(someFunctionThatTakesNoArgumentAndReturnsCompletableFuture)
  </code></pre>
  <p>However I see the usage is</p>
  <pre><code>override fun getUserInfo(userId: String) =
      catchAsyncExceptions {
          membersClient.getUserLocation(
              GetUserLocationRequest(userId)
          )
              .thenApply { response -&gt;
                  val (success, error) = parseSuccessAndError&lt;GetUserLocationResponseResult.Success&gt;(response.result!!)
                  error?.let {
                      UserInfoResponse(
                          error = error.code
                          )
                      )
                  } ?: run {
                      UserInfoResponse(
                          data = UserInfoResponseDto(
                              location = success?.success?.location.toString(),
                          )
                      )
                  }
              }
      }
  </code></pre>
  <p>Note that</p>
  <pre><code>membersClient.getUserLocation(
              GetUserLocationRequest(userId)
          )
  </code></pre>
  <p>returns <code>CompletableFuture</code> type</p>
  <p>I am especially confused why it was a curly bracket rather than a bracket</p>
  <pre><code>catchAsyncExceptions {
  ...
  }
  </code></pre>