Coder Social home page Coder Social logo

Comments (2)

eernstg avatar eernstg commented on July 20, 2024

v is VariableMirror is the relevant test if you want to check whether the run-time type of the object which is bound to v is a subtype of VariableMirror.

The test v.runtimeType is VariableMirror is just another way to write false, because v.runtimeType is a reified type, that is, an object of type Type which is a representation of the run-time type of v, and an object of type Type is never of type VariableMirror (except for completely pathological examples where you want to prove that it can be done ;-).

It's similar to looking at v.getClass().getClass() in Java. You want v.getClass() instead, and in Dart that job is done by is.

In any case, this would allow you to look at all the declarations in the class mirrored by classMirror, and selecting the ones that are variable declarations (static variables or instance variables). I assume this is also what you want to do.

PS: 'value type' is a dangerous phrase to use, because there is a concept known as the 'Future value type' of an async function. For Future<int> f(int i) async { return i; } the future value type is int. So it's better to just talk about the 'type of an object', which is some DeclarationMirror in this case, and then it's unimportant that we used .values in order to get hold of it.

from reflectable.dart.

eernstg avatar eernstg commented on July 20, 2024

I'll close this issue, it's working as intended.

from reflectable.dart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.