You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Say you have some logic that may return nil, but you don't want to cache nil... Is this something where we could do this?
cache.fetch(key, as:String) do
[nil, "string"].sample
end
With this, I specify that the value is String, but if it returns nil, then we don't cache it. Running it again would only cache if the value returns "string". However, doing this...
cache.fetch(key, as:String?) do
[nil, "string"].sample
end
would say that I allow a nil value, so cache whatever I get back, even if it's nil.
I think we can catch that at compile-time and alter the logic. But the question is, would that be nice? Or would that cause issues?
The text was updated successfully, but these errors were encountered:
Say you have some logic that may return nil, but you don't want to cache nil... Is this something where we could do this?
With this, I specify that the value is
String
, but if it returnsnil
, then we don't cache it. Running it again would only cache if the value returns"string"
. However, doing this...would say that I allow a nil value, so cache whatever I get back, even if it's nil.
I think we can catch that at compile-time and alter the logic. But the question is, would that be nice? Or would that cause issues?
The text was updated successfully, but these errors were encountered: