Skip to content

Files

Latest commit

 

History

History
23 lines (14 loc) · 506 Bytes

FunctionOnlyReturningConstant.md

File metadata and controls

23 lines (14 loc) · 506 Bytes

Pattern: Function only returning constant

Issue: -

Description

A function that only returns a single constant can be misleading. Instead prefer to define the constant directly as a const val.

Example of incorrect code:

fun functionReturningConstantString() = "1"

Example of correct code:

const val constantString = "1"

Further Reading