I am facing an error in following script :
i=1
if(i==1)
{
print("done")
}
else
{
print('Not done')
}
Error which I am getting :
script.R:6:1: unexpected 'else'
5: }
6: else
But when I make the script a function, i.e. :
f=function()
{
i=1
if(i==1)
{
print("done")
}
else
{
print('Not done')
}
}
It runs just fine. Am I doing anything wrong in my first script or this is an expected behaviour?
The answer here to change the bracket works, but can anyone pls share why this inconsistency ?