how to see if transform has child?

is there a simple code to access the first child of a parent I know about

for (var child : Transform in transform) {
    // do whatever you want with child transform here
}

but I kinda want something like this

if (var child : Transform in transform)
{
//do this
}

because I just have one child under this object if there is one at all. or maybe a way to just see if transform is a parent or not?

If a transform has a child

if(transform.childCount > 0) //do something

will only execute something if there is a child.

Foreach

for (var child : Transform in transform) {
    // do whatever you want with each child transform here
}

doesn't access just the first child, but rather every immediate child of the transform. If you have no children in the transform, it will never go into this block. It is semantically the same as:

for(var i : int = 0; i < transform.childCount; i++) {
    var child : Transform = transform*;*
 *// do whatever you want with each child transform here*
*}*
*```*
*<p>which will check the loop condition before performing any iterations. If transform.childCount is 0, then i >= transform.childCount when i = 0 on the first iteration and the loop will exit before doing anything.</p>*
*<p>In JavaScript, the foreach loop which loops through every something in something else is written as:</p>*
*```*
*for(var something : Thing in somethingElse) {*
 *// do whatever you want with each something here*
*}*
*```*
*<p>which is semantically the same as:</p>*
*```*
*for(var i : int = 0; i < somethingElse.length; i++) {*
 _var something : Thing = somethingElse*;*_
 _*// do whatever you want with each something here*_
_*}*_
_*```*_

In c#
foreach (Transform child in Children) {
// whatever
}