I don't know if the title is appropriate, but
class Hoge
def fuga
{:piyo=>1}
end
end
If there is a class like this, I think it will be used as follows.
hoge=Hoge.new
hoge.fuga[:piyo]#=>1
What is the best way to do it if you want to be able to see it in hoge.fuga.piyo
as well?
If the number is small and the key is fixed, I think it can be a method or instance variable, but
Is it possible to implement it so that even if the contents of the hash (including the key) change dynamically?
Thank you for your cooperation.
ruby
How about OpenStruct
(require'ostruct'
)?
540 Uncaught (inpromise) Error on Electron: An object could not be cloned
727 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
549 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
548 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.