我试图理解这个代码片段:
class Worker
{
public bool DoThisJob(string job, int numberOfShifts)
{
if (!String.IsNullOrEmpty(currentJob))
return false;
for (int i = 0; i < jobsICanDo.Length; i++)
if (jobsICanDo[i] == job)
{
currentJob = job;
this.shiftsToWork = numberOfShifts;
shiftsWorked = 0;
return true;
}
return false;
}
}
如果这个if
语句有不止一行代码(包括for
循环和两个return
s),为什么它没有花括号?