Accessing script variables in objects in an array.

Hello and thanks for you time.

I am trying desperately to access variables in an array of game objects but haven't been able do it. The below code snippet it supposed to go through the GO's in the array and declare the go with he highest bestBubValue to be the bestBubble.

    for (i = 0; i < bubArray.length; i++)
{
    if (((Bubble)bubArray*).bestBubValue >= currentBestValue)* 
 *{*
 _bestBubble = (Bubble)bubArray*;*_
 <em>_currentBestValue = ((Bubble)bubArray*).bestBubValue;*_</em> 
 <em>_*}*_</em>
<em>_*}*_</em>
<em>_*```*_</em>
<em>_*<p>I think I need to cast it somehow but don't understand how it works (or really what "casting" even is.)  Save me Superman!</p>*_</em>

Well, by parroting this answer I ended up with this code which seems to work:

    for (var bub : GameObject in bubArray)
{
    bubbleScript = bub.GetComponent(Bubble);
    bubbleScript.setBestBubValue();

    if (bubbleScript.bestBubValue >= currentBestValue)
    {
        bestBubble = bub;
        currentBestValue = bubbleScript.bestBubValue;
        Debug.Log("THIS IS THE BEST BUBBLE " + bestBubble.name);    
    }       
}

I guess I casted? :)