Skip to content

open doesn't return block result #413

@toy

Description

@toy

Normally I expect open method to initialise something, yield it, ensure closing and return result of block. For example for File I will get 10 bytes from /dev/zero in result variable:

result = File.open('/dev/zero') do |f|
  f.read(10)
end

This is not the case for SQLite3::Database.open, as it is an alias to method new, so when called with block, it will return the already closed instance of SQLite3::Database instead of block result.
Is there a reason not to return block result? Otherwise what do you think about changing this? From one side it is a breaking change, as someone maybe relying on it, from the other side - it is not explicitly documented that open will not return block result when called with block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions