Complete the code to create a successful Result with value 42.
val result: Result<Int> = Result.[1](42)
Use Result.success(value) to create a successful Result wrapping the value.
Complete the code to create a failed Result with an exception.
val errorResult: Result<Int> = Result.[1](IllegalArgumentException("Invalid input"))
Use Result.failure(exception) to create a failed Result wrapping the exception.
Fix the error in the code to catch exceptions and return a Result.
val result = Result.[1] { 10 / 0 }
runCatching runs the lambda and catches exceptions, returning a Result.
Fill both blanks to create a map operation on a Result.
val mapped = result.[1] { it [2] 2 }
Use map to transform the success value, and * to multiply by 2.
Fill all three blanks to handle success and failure with fold.
val message = result.[1]( onSuccess = { "Success: " + it.toString() }, onFailure = { [2] -> "Error: " + [3].message } )
fold handles both success and failure. The failure lambda parameter is named e to access the exception.
