Bug #10113

Ruby memoization behaving oddly when using hash keys with spaces

Added by Ron Arias 8 months ago. Updated 6 months ago.

[ruby-core:64227]
Status:Rejected
Priority:Normal
Assignee:ruby-core
ruby -v:ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin12.0] Backport:2.0.0: UNKNOWN, 2.1: UNKNOWN

Description

Trying to use simple Hash memoization with a ruby hash in a class method, it "fails" when having spaces as the hash key. Example code is attached.
When calling the memoization method, it fails to maintain the instance variable. It resets the variable every time the method is called.
When not having spaces in the key of the Hash, it works as it should, memoizing the variable.

P.S. Despite my ruby version indicated bellow, it fails in the newest as well.

memoization_issue.rb Magnifier (305 Bytes) Ron Arias, 08/06/2014 10:08 AM

History

#1 Updated by Franck Verrot 8 months ago

Ron Arias wrote:

Trying to use simple Hash memoization with a ruby hash in a class method, it "fails" when having spaces as the hash key. Example code is attached.
When calling the memoization method, it fails to maintain the instance variable. It resets the variable every time the method is called.
When not having spaces in the key of the Hash, it works as it should, memoizing the variable.

I can only reproduce the behavior you are describing if I make the "heavy_calculations" method return nil or false. Do you have any specific work done in this method?

P.S. Despite my ruby version indicated bellow, it fails in the newest as well.

I run on ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0].

#2 Updated by Tomoyuki Chikanaga 7 months ago

  • Status changed from Open to Feedback

Hello, Ron. Thank you for your report.
But I cannot understand what is the "fail" you mean. Please give us a self-contained executable script to clarify the point.

Thanks.

#3 Updated by Marc-Andre Lafortune 6 months ago

  • Status changed from Feedback to Rejected

No feedback, so closing.
I can't see how this could possibly "fail".

Also available in: Atom PDF