Implicit Conversion

In this chapter we are going to learn about the Implicit Conversion

Introduction

Rules:

String + Number ---> String     # Merge Strings (Number will be converted to a String)
Number + String ---> Number     # Sum Numbers (String will be converted to a Number)

We will create a simple program to learn how to use the Implicit Conversion

We can create this program quickly using the Quick Start component

ib_quickstart_implicitconversion.png

Program Steps

After selecting the (Implicit Conversion) template, we will get the next steps in the Goal Designer

gd_quickstart_implicitconversion.png

Creating the Program

To create this program we will use the next components

  • Assignment

  • Print Text

In the begining the Steps Tree is empty

1.png

Select the (Assignment) component

2.png

Enter the data in the Interaction Page

Left side: x

Right side: 10

3.png

The Steps Tree will be updated

4.png

Set y = “20”

5.png 6.png

The Steps Tree will be updated

7.png

Set sum = x + y

X is a Number

Y is a String

X + Y —> Number + String —> Number

8.png 9.png 10.png

Set msg = “Sum = ” + sum

“Sum = ” is a String

sum is a Number

“Sum = ” + sum —> String + Number —> String

11.png 12.png 13.png

Print the Msg variable

14.png 15.png

Now we have the final Steps Tree in our program

16.png