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

CountTable raisen error instead of returning a count of 0 #10065

Closed
filipux opened this issue Dec 21, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@filipux
Copy link

commented Dec 21, 2018

Summary

CountTable should be able to return a count of zero. Today it throws a "key not found" exception when the count is zero; a behaviour that is perfectly sensible for a hash table but not for a CountTable.

We have getOrDefault() that works like requested but it makes sense to make it the default get behaviour of CountTable.

Description

Current behaviour:
echo toCountTable("abracadabra")['a'] returns 5
echo toCountTable("abracadabra")['z'] throws error

Suggested behaviour:
echo toCountTable("abracadabra")['a'] returns 5
echo toCountTable("abracadabra")['z'] returns 0

@filipux filipux changed the title CountTable should be able to return 0 CountTable should be able to return a count of 0 Dec 21, 2018

@krux02 krux02 changed the title CountTable should be able to return a count of 0 CountTable raisen error instead of returning a count of 0 Dec 21, 2018

@Araq Araq added the RFC: Accepted label Dec 21, 2018

@narimiran narimiran closed this in b78af99 Jan 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.