Skip to content

Conversation

@Bristina
Copy link

Summary

The example for the apply function can be misleading. By commenting the output after the getData function is called in main, one might understand that apply is lazy loading.

Changes

  • Print a message in the getData function. This way, it will be obvious when this function is being called
  • For the apply example, move the output from the connect and authenticate function at beginning of main. This way, it will be obvious that these functions are not triggered by the getData call

@Bristina Bristina requested a review from a team as a code owner November 16, 2025 14:18
@Bristina
Copy link
Author

Let me know if this makes sense!

fun connect() = println("connected!")
fun authenticate() = println("authenticated!")
fun getData(): String = "Mock data"
fun getData() : String {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could have been kept as a single expression function with also after it, but also is explained after apply (and i'd avoid it using it anyway while explaining scope functions)

@sarahhaggarty sarahhaggarty self-assigned this Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants