BotsBurgh / BOTSBURGH-FTC-2024-25

Code for our FTC 2024-25 season robot
https://botsburgh.github.io/BOTSBURGH-FTC-2024-25/
GNU General Public License v2.0
3 stars 0 forks source link

Create shortcut for `if (RobotConfig.debug)` for `Logging` #55

Closed BD103 closed 1 month ago

BD103 commented 3 months ago

A lot of functions in Logging only do something if RobotConfig.debug = true:

fun write(...) {
    if (RobotConfig.debug) {
        // ...
    }
}

This can be substituted for a shortcut function that takes a function as a receiver:

fun write(...) = ifDebug {
    // ...
}

This can work through Kotlin's trailing functions, where can desugar myFunction { ... } into myFunction({ ... }).