|
| 1 | +{ |
| 2 | + "meta": { |
| 3 | + "language": "kotlin", |
| 4 | + "language_name": "Kotlin", |
| 5 | + "structure": "functions", |
| 6 | + "language_version": "1.5" |
| 7 | + }, |
| 8 | + "concepts": { |
| 9 | + "void_function_no_parameters": { |
| 10 | + "code": "fun functionName() {\n // statements\n}", |
| 11 | + "name": "Function that does not return a value and takes no parameters" |
| 12 | + }, |
| 13 | + "void_function_with_parameters": { |
| 14 | + "code": "fun functionName(param1: Type, param2: Type) {\n // statements\n}", |
| 15 | + "name": "Function that does not return a value and that takes 1 or more defined parameters" |
| 16 | + }, |
| 17 | + "void_function_with_optional_parameters": { |
| 18 | + "code": "fun functionName(param1: Type, param2: Type = defaultValue) {\n // statements\n}", |
| 19 | + "name": "Function that does not return a value and that takes 1 or more optional parameters (with default values)" |
| 20 | + }, |
| 21 | + "void_function_variable_parameters": { |
| 22 | + "code": "fun functionName(vararg params: Type) {\n // statements\n}", |
| 23 | + "name": "Function that does not return a value and function that takes an unknown number of parameters" |
| 24 | + }, |
| 25 | + "return_value_function_no_parameters": { |
| 26 | + "code": "fun functionName(): ReturnType {\n // statements\n return expression\n}", |
| 27 | + "name": "Function that returns a value and takes no parameters" |
| 28 | + }, |
| 29 | + "return_value_function_with_parameters": { |
| 30 | + "code": "fun functionName(param1: Type, param2: Type): ReturnType {\n // statements\n return expression\n}", |
| 31 | + "name": "Function that returns a value and takes 1 or more defined parameters" |
| 32 | + }, |
| 33 | + "return_value_function_with_optional_parameters": { |
| 34 | + "code": "fun functionName(param1: Type, param2: Type = defaultValue): ReturnType {\n // statements\n return expression\n}", |
| 35 | + "name": "Function that returns a value and takes 1 or more optional parameters (with default values)" |
| 36 | + }, |
| 37 | + "return_value_function_variable_parameters": { |
| 38 | + "code": "fun functionName(vararg params: Type): ReturnType {\n // statements\n return expression\n}", |
| 39 | + "name": "Function that returns a value and takes an unknown number of parameters" |
| 40 | + }, |
| 41 | + "anonymous_function_no_parameters": { |
| 42 | + "code": "{ -> // statements }", |
| 43 | + "name": "Anonymous function that takes no parameters" |
| 44 | + }, |
| 45 | + "anonymous_function_with_parameters": { |
| 46 | + "code": "{ param1: Type, param2: Type -> // statements }", |
| 47 | + "name": "Anonymous function that takes 1 or more defined parameters" |
| 48 | + }, |
| 49 | + "anonymous_function_variable_parameters": { |
| 50 | + "not-implemented": true, |
| 51 | + "name": "Anonymous function that takes an unknown number of parameters" |
| 52 | + }, |
| 53 | + "anonymous_function_no_parameters_with_return": { |
| 54 | + "code": "{ -> expression }", |
| 55 | + "name": "Anonymous function that takes no parameters and returns a value" |
| 56 | + }, |
| 57 | + "anonymous_function_with_parameters_with_return": { |
| 58 | + "code": "{ param1: Type, param2: Type -> expression }", |
| 59 | + "name": "Anonymous function that takes 1 or more defined parameters and returns a value" |
| 60 | + }, |
| 61 | + "extension_function": { |
| 62 | + "code": "fun ReceiverType.functionName() {\n // statements\n}", |
| 63 | + "comment": "Extension functions allow you to add new functions to existing classes without inheriting from them.", |
| 64 | + "name": "Extension functions" |
| 65 | + }, |
| 66 | + "named_arguments": { |
| 67 | + "code": "functionName(param2 = value2, param1 = value1)", |
| 68 | + "name": "Named arguments in function calls" |
| 69 | + }, |
| 70 | + "async_function": { |
| 71 | + "code": "suspend fun functionName() {\n // statements\n}", |
| 72 | + "name": "Asynchronous function (async/await)" |
| 73 | + } |
| 74 | + } |
| 75 | +} |
0 commit comments