Dart programming for all

  I am using the online compiler, Dartpad.

I am starting off with writing my own name

This was my code.



Here is the output. 

Where I make a lot of mistakes

I will keep this syntax intact and try to print more strings.



Here is another input. I have not used '' so I get an error. 



Missing out the ; also creates an error. 

Can I print a number?







Yes, I can. And, notice how the variable, name, changed from a string to an integer type. 

The output is 56.

Can I add two numbers?



Yes, the output is 118. 

Can I store the value of the sum into a third variable?




Yes, the output is 118 again. 

I made a mistake that I did not write 'var' before name3. I later corrected it for it had returned an error. 

What if I want name to hold only a string and name1 to hold only an integer? Is there a way out? After all, var name or var name1 can take either strings or integers. 

We can define the variable type of name as a string and that of name1 as an integer. Then I will not make any mistakes in assigning values. Even if I did make a mistake, dart would show me an error message.


It turned out that Dart is case sensitive. string was returning an error. I had to write StringInt did not work but int did. Yes, I got the correct outputs for both these inputs. 

Let us assign 23 to name. 




Bookmark this honest notebook of a student for it will keep increasing in the future. 

Comments

Popular posts from this blog

Diary -24th July

How to make clip art faces-Part 1: Pretty girl face with braided hair decorated with flowers

Object oriented programming in dart concepts