# Question regarding Object Tree Page 62 \[PDF\]

**URL:** <https://forums.kodeco.com/t/question-regarding-object-tree-page-62-pdf/180773>\
**Category:** Dart Apprentice: Fundamentals\
**Created:** [November 10, 2022, 3:54am UTC](https://forums.kodeco.com/t/question-regarding-object-tree-page-62-pdf/180773 "2022-11-10T03:54:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![avinashd](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/avinashd/32/102075_2.png) [@avinashd](https://forums.kodeco.com/u/avinashd)\
**Post date:** [November 10, 2022, 3:54am UTC](https://forums.kodeco.com/t/question-regarding-object-tree-page-62-pdf/180773/1 "2022-11-10T03:54:48Z")

</div>

Where does ‘var’ and ‘dynamic’ fit into the object tree?

---

<div class="post-metadata">

**Author:** ![suragch](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/suragch/32/109020_2.png) [@suragch](https://forums.kodeco.com/u/suragch)\
**Post date:** [November 10, 2022, 5:38am UTC](https://forums.kodeco.com/t/question-regarding-object-tree-page-62-pdf/180773/2 "2022-11-10T05:38:07Z")

</div>

`var` and `dynamic` are not objects (or types) themselves so they don’t fit into the object tree.

# var

`var` is a keyword and is short for “variable”. When you use it you are letting Dart infer the type from whatever the value of the variable is. For example:

```auto
var x = 1;

```

Since `1` is an integer, Dart infers the type to be `int`. You use `var` to tell Dart that you want to change the value later. Like this:

```auto
var x = 1;
x = 2;

```

`var`, `final` and `const` all are related keywords because they all let Dart infer the type.

# dynamic

`dynamic` is also not really a type by itself. Rather, you use this keyword to tell Dart that you don’t want to use any type checking. This is fine:

```auto
dynamic x = 1;
x = 'hello';
x = true;
x = null;

```

If you want to compare `dynamic` to a type, it is most similar to `Object?` since everything is a subtype of `Object?`, even nullable values. This is fine:

```auto
Object? x = 1;
x = 'hello';
x = true;
x = null;

```

However, saying that you can use any object type (`Object?`) is not quite the same as saying that you don’t care about the type (`dynamic`).

---

<div class="post-metadata">

**Author:** ![avinashd](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/avinashd/32/102075_2.png) [@avinashd](https://forums.kodeco.com/u/avinashd)\
**Post date:** [November 10, 2022, 8:51pm UTC](https://forums.kodeco.com/t/question-regarding-object-tree-page-62-pdf/180773/3 "2022-11-10T20:51:18Z")

</div>

@suragch makes sense. Thank you for your reply.

---

<div class="post-metadata">

**Author:** ![eshfield](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/eshfield/32/105896_2.png) [@eshfield](https://forums.kodeco.com/u/eshfield)\
**Post date:** [January 15, 2023, 9:27am UTC](https://forums.kodeco.com/t/question-regarding-object-tree-page-62-pdf/180773/4 "2023-01-15T09:27:58Z")

</div>

Just to clarify — I can’t see anything about `var`, `dynamic` or object tree at the page 62 of PDF version of **Dart Apprentice: Fundamentals book**. Looks like you are talking about another book, aren’t you?

---

<div class="post-metadata">

**Author:** ![suragch](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/suragch/32/109020_2.png) [@suragch](https://forums.kodeco.com/u/suragch)\
**Post date:** [January 16, 2023, 5:52am UTC](https://forums.kodeco.com/t/question-regarding-object-tree-page-62-pdf/180773/5 "2023-01-16T05:52:56Z")

</div>

The keywords `var` and `dynamic` are discussed elsewhere in _Dart Apprentice: Fundamentals_, just not on that particular page. These keywords occur in the same location when declaring a variable as type names like `Object`, `int` and `String` do, so it’s easy to assume that `var` and `dynamic` should also fit somewhere into the hierarchy of Dart types represented by the Object Tree diagram. I believe that’s what led to the original question from the reader above.
