I have an object like this
class SomeObject
def initialize &block
# do something
end
end
class AnotherObject < SomeObject
def initalize &block
super
# do something with block
end
end
When super
is called in AnotherObject
, the block seems to be passed to SomeObject
. Is this the right behaviour and is there away round it?
Block objects are a C-level syntactic and runtime feature that allow you to compose function expressions that can be passed as arguments, optionally stored, and used by multiple threads. The function expression can reference and can preserve access to local variables.
Object storage is best used for large amounts of unstructured data, especially when durability, unlimited storage, scalability, and complex metadata management are relevant factors for overall performance. Block storage provides low latency and high-performance values in various use cases.
File storage organizes and represents data as a hierarchy of files in folders; block storage chunks data into arbitrarily organized, evenly sized volumes; and object storage manages data and links it to associated metadata. Containers are highly flexible and bring incredible scale to how apps and storage are delivered.
The most common examples of Block Storage are SAN, iSCSI, and local disks. Block storage is the most commonly used storage type for most applications. It can be either locally or network-attached and are typically formatted with a file system like FAT32, NTFS, EXT3, and EXT4.
According to rubyspec this is the correct behaviour, even if you pass explicit arguments to super (i.e. super('foo')
)
If you don't want to pass that block, you could just pass a block that does nothing, although this isn't quite the same thing (e.g. if the method changes its behaviour based on block_given?
)
It appears that
super(&nil)
is a way to pass no block at all to super, although I couldn't find this in ruby spec.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With