# Error in creating own data type

**URL:** https://discourse.julialang.org/t/error-in-creating-own-data-type/28178
**Category:** New to Julia
**Created:** [August 29, 2019, 7:16pm UTC](https://discourse.julialang.org/t/error-in-creating-own-data-type/28178 "2019-08-29T19:16:05Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![iamsuddhasattwa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iamsuddhasattwa/32/7441_2.png) [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)
#### Post date: [August 29, 2019, 7:16pm UTC](https://discourse.julialang.org/t/error-in-creating-own-data-type/28178/1 "2019-08-29T19:16:05Z")

</div>

I am trying to create my own pointer structure for a binary tree. I am starting with this simple code

```julia
type int_BST
    key::Int64
    left::Nullable{int_BST}
    right::Nullable{int_BST}
end

```

but I keep getting the error

```julia
ERROR: LoadError: syntax: extra token "int_BST" after end of expression
Stacktrace:
 [1] include at ./boot.jl:326 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1038
 [3] include(::Module, ::String) at ./sysimg.jl:29
 [4] include(::String) at ./client.jl:403
 [5] top-level scope at none:0
in expression starting at /data/dass/Julia/int_BST.jl:1

```

I realize this is a very basic issue, and any help would be appreciated.

---

<div class="post-metadata">

### Author: ![favba](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/favba/32/2735_2.png) [@favba](https://discourse.julialang.org/u/favba)
#### Post date: [August 29, 2019, 8:13pm UTC](https://discourse.julialang.org/t/error-in-creating-own-data-type/28178/2 "2019-08-29T20:13:51Z")

</div>

The keyword for creating a struct is `struct` (it used to be `type` on older version of julia but it isn’t anymore):

```julia
mutable struct int_BST
    key::Int64
    left::Nullable{int_BST}
    right::Nullable{int_BST}
end

```

see: [Types · The Julia Language](https://docs.julialang.org/en/v1/manual/types/#Composite-Types-1)

If I’m not mistaken, `Nullable` is not used anymore. I’m guessing you are looking for something like:

```julia
mutable struct int_BST
    key::Int64
    left::Union{int_BST,Nothing}
    right::Union{int_BST,Nothing}
end

```

and use `nothing` (the instance of the `Nothing` type).

---

<div class="post-metadata">

### Author: ![iamsuddhasattwa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iamsuddhasattwa/32/7441_2.png) [@iamsuddhasattwa](https://discourse.julialang.org/u/iamsuddhasattwa)
#### Post date: [August 29, 2019, 9:11pm UTC](https://discourse.julialang.org/t/error-in-creating-own-data-type/28178/3 "2019-08-29T21:11:17Z")

</div>

Thank you very much for the quick reply, that worked. I will also check the link that you sent.
