public function substring( $beginIndex, $endIndex = null ) {
		if ( $beginIndex < 0 ) {
			throw new GStringIndexOutOfBoundsException( $beginIndex );
		} else if ( $beginIndex == $this->length() ) {
			return new GString( "" );
		}
		if ( $endIndex === null ) {
			$length = $this->length() - $beginIndex;
			if ( $length < 0 ) {
				throw new GStringIndexOutOfBoundsException( $length );
			}
			if ( $beginIndex == 0 ) {
				return $this;
			} else {
				return new GString( $this->value, $beginIndex, $length );
			}
		} else {
			if ( $endIndex > $this->length() ) {
				throw new GStringIndexOutOfBoundsException( $endIndex );
			}
			$length = $endIndex - $beginIndex;
			if ( $length < 0 ) {
				throw new GStringIndexOutOfBoundsException( $length );
			}
			if ( $beginIndex == 0 && $endIndex == $this->length() ) {
				return $this;
			} else {
				return new GString( $this->value, $beginIndex, $length );
			}
		}
	}