Search code examples
eiffel

Eiffel: How to get class of a Void object? is it possible?


I have a void object which I declared, but want to get its class name is it possible??

item: detachable DB_ENTITY

db_connection.base_selection.query("SELECT * FROM " + item.generating_type.out)

Creating it is not what I want...


Solution

  • A type object (i.e. an object like the one returned by generating_type for an existing object) can be obtained using curly braces enclosing the type name:

        {MY_TYPE}
    

    In your example it would be {attached like item} if item is a feature (of type detachable DB_ENTITY to allow for a value Void), or {DB_ENTITY} if item is a local variable, so that the whole expression would read in one of the following ways:

      db_connection.base_selection.query("SELECT * FROM " + ({attached like item}).out)
      db_connection.base_selection.query("SELECT * FROM " + ({DB_ENTITY}).out)
    

    In the second case, the corresponding string would be equivalent to "SELECT * FROM DB_ENTITY".