Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Rubyを学んでいます。mysqlgemを使用して MySQL db に接続しようとしています。私の懸念の1つは、接続の閉鎖です。
mysql
例外のスローなど、予期しない状況で接続を確実に閉じるにはどうすればよいですか?
つまり、このようなものですか?
begin db = open_mysql_connection # do stuff ensure # this block is always executed, even if exception is raised db.close end