Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!

sachin kmittal

Greenhorn
+ Follow
since May 22, 2020
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sachin kmittal

My understanding was that if there is only statement in a code block, parentheses ({}) can be skipped. In the below code snippets, first 3 are working fine but last 2 was showing compiler error. This in not practical code but want to understand the concepts.

// #Code 1
if (true)  {
int i=4;
}

// #Code 2

if (true) {
int i;
}

// #Code 3

int i;
if (true)  
i=4;

// #Code 4
if (true)  
int i=4; //ERROR

// #Code 5
if (true)  //ERROR
int i;