Skip to content

Conversation

@Masynchin
Copy link
Contributor

#287 (comment) - done!

The only difference expect for naming, is the usage of traverse_ instead of traverse.

Is there possibility and necessity to replace state.updated with state.add? Should be other methods be renamed?

@Masynchin
Copy link
Contributor Author

For the given code block:

val io = maybeGivenUp.traverse_(task =>
  Logger[IO].warn(s"Give up move due to invalid move $response by $key for $task")
)

I was trying to use new function syntax with maybeGivenUp.traverse_: task =>, but got syntax error, strange

@lenguyenthanh
Copy link
Member

The only difference expect for naming, is the usage of traverse_ instead of traverse.

This is a good optimization 👍

Is there possibility and necessity to replace state.updated with state.add? Should be other methods be renamed?

They're the same but also not quite.
AppState is an opaque type with the underlying type is a Map. For object outside of AppState, they can't access to Map's functions they can only access to what We define in AppState object. So that's why we can use state.updated in AppState, but in Executor We need to use state.add

@lenguyenthanh
Copy link
Member

I was trying to use new function syntax with maybeGivenUp.traverse_: task =>, but got syntax error, strange

So, any function that ends with symbol cannot use fewer braces syntax.

@lenguyenthanh lenguyenthanh merged commit 7463f49 into lichess-org:master Mar 14, 2024
@Masynchin
Copy link
Contributor Author

So, any function that ends with symbol cannot use fewer braces syntax.

TIL, thanks!

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