Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cron.New().Remove() #505

Open
tuye01 opened this issue Oct 11, 2023 · 1 comment
Open

cron.New().Remove() #505

tuye01 opened this issue Oct 11, 2023 · 1 comment

Comments

@tuye01
Copy link

tuye01 commented Oct 11, 2023

code:
id := 1
cron.New().Remove(1)
cron.New().Remove(id)
question:

  1. The parameter requirement is EntryID, why is 1 possible?
  2. 1 There is no error, why can't the id?
@janrnc
Copy link

janrnc commented Oct 13, 2023

Hi @tuye01
it's probably a matter of type inference.

The parameter requirement is EntryID, why is 1 possible?

Here you're assigning the numeric literal directly to the argument and therefore the inferred (or implicitly converted?) type corresponds to the required one. This is possible because cron.EntryID is an alias typedef for int.

There is no error, why can't the id?

While here you first assign the literal to id, which makes the variable have type int and then when you call cron.New().Remove(id) the types do not match.

In fact, if you explicitly type the variable var id cron.EntryID = 1 the removal runs as expected.

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

No branches or pull requests

2 participants