# Says missing curly brackets, but they're all there

**URL:** <https://discourse.processing.org/t/says-missing-curly-brackets-but-theyre-all-there/2059>\
**Category:** Coding Questions\
**Created:** [July 25, 2018, 3:54am UTC](https://discourse.processing.org/t/says-missing-curly-brackets-but-theyre-all-there/2059 "2018-07-25T03:54:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![donotread123](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/donotread123/32/883_2.png) [@donotread123](https://discourse.processing.org/u/donotread123)\
**Post date:** [July 25, 2018, 3:54am UTC](https://discourse.processing.org/t/says-missing-curly-brackets-but-theyre-all-there/2059/1 "2018-07-25T03:54:14Z")

</div>

Unless I’m missing something, this code should be correct. My goal was to make a circle (“Bubble”) which would be a random color. however, it says that I am missing curly brackets  
“{” missing on line 4: `int color = int(random(0, 7));`  
and “}” missing on line 38: `}`

Here is the full tab:

```auto
class BubRandCol
{
  int[] rgb = new int[3];
  int color = int(random(0, 7));
  
  if(color == 0)
  {
    int[] rgb = {255,0,0};
  }
  if(color == 1)
  {
    int[] rgb = {255,128,0};
  }
  if(color == 2)
  {
    int[] rgb = {255,255,0};
  }
  if(color == 3)
  {
    int[] rgb = {0,255,0};
  }
  if(color == 4)
  {
    int[] rgb = {0,0,255};
  }
  if(color == 5)
  {
    int[] rgb = {128,0,128};
  }
  if(color == 6)
  {
    int[] rgb = {0,0,0};
  }
  if(color == 7)
  {
    int[] rgb = {255,255,255};
  }
}

```

The only other tab I have says this:

```auto
void setup()
{
  size(700, 500);
}

```

---

<div class="post-metadata">

**Author:** ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)\
**Post date:** [July 25, 2018, 5:53am UTC](https://discourse.processing.org/t/says-missing-curly-brackets-but-theyre-all-there/2059/2 "2018-07-25T05:53:14Z")

</div>

You can’t have code like this in he middle of your class: you can just declare your variables here.

If you want to write some algorithm, you need to put them inside functions like so:

```auto
class BubRandCol
{
  int[] rgb = new int[3];
  int color = int(random(0, 7));
  
  void BubRandCol() {
    if(color == 0)
    {
      int[] rgb = {255,0,0};
    }
    if(color == 1)
    {
      int[] rgb = {255,128,0};
    }
    if(color == 2)
    {
      int[] rgb = {255,255,0};
    }
    if(color == 3)
    {
      int[] rgb = {0,255,0};
    }
    if(color == 4)
    {
      int[] rgb = {0,0,255};
    }
    if(color == 5)
    {
      int[] rgb = {128,0,128};
    }
    if(color == 6)
    {
      int[] rgb = {0,0,0};
    }
    if(color == 7)
    {
      int[] rgb = {255,255,255};
    }
  }
}

```

No more curly brackets problem 👍
