B1 Confusable-words 10 min read متوسط

If در مقابل Else-if در مقابل Elsif: تفاوت چیست؟

کلمه کلیدی if شرط اصلی رو شروع می‌کنه، else if شرط بعدی رو چک می‌کنه، و elsif یه شکل کوتاه‌تر و مخصوص بعضی زبون‌هاست.

Grammar Rule in 30 Seconds

Use 'if' to start a condition, 'else' for the alternative, and 'else if' for a second specific option.

  • Use 'if' for your first condition: 'If it rains, stay inside.' (max 20 words)
  • Use 'else' for everything else: 'If it's sunny, go out; else, stay home.'
  • Use 'else if' for a middle option: 'If it's hot, swim; else if it's cool, hike.'
Condition 1 (If) ➡️ Option A | Condition 2 (Else If) ➡️ Option B | No Condition (Else) ➡️ Option C

مرور کلی

### Overview
در دنیای زبان انگلیسی و به‌ویژه در متون فنی و برنامه‌نویسی، درک تفاوت میان if، else if و elsif فراتر از یک بحث ساده دستوری است؛ این موضوع در واقع درکِ «منطق شرطی» است. ما در زبان فارسی برای بیان این مفهوم از کلمات «اگر»، «وگرنه» یا «در غیر این صورت» استفاده می‌کنیم، اما در انگلیسی، ساختار این تصمیم‌گیری‌ها بسیار دقیق‌تر و ساختاریافته‌تر است. برای یک فارسی‌زبان، درک این نکته حیاتی است که در انگلیسی، برخلاف مکالمات روزمره فارسی که ممکن است جملات شرطی را با لحن یا ترتیب‌های مختلف بیان کنیم، این کلمات یک مسیرِ منطقیِ پله‌کانی را ترسیم می‌کنند.
تصور کنید در یک کافه در تهران هستید و می‌خواهید سفارش بدهید: «اگر چای موجود است، چای بیاور؛ وگرنه اگر قهوه دارید، قهوه بیاور؛ در غیر این صورت آب‌میوه بیاور.» این دقیقاً همان ساختار شرطی است. در انگلیسی، استفاده از if برای شرط اول، else if برای شرط‌های بعدی و else برای حالت نهایی، به شما اجازه می‌دهد تا مسیرِ تصمیم‌گیری را برای شنونده یا خواننده کاملاً شفاف کنید. این ساختار در انگلیسی به جای تکرارِ مداومِ «اگر»، از یک روندِ متوالی (Sequential Evaluation) پیروی می‌کند.
تفاوت اصلی در این است که در فارسیِ محاوره، ما گاهی جملات را بدون نظمِ منطقیِ سخت‌گیرانه می‌چینیم، اما در انگلیسی، این کلمات به عنوان «راهنمایِ جریانِ فکر» عمل می‌کنند. یادگیری این ساختار به شما کمک می‌کند تا در محیط‌های کاری یا آکادمیک، منظور خود را با دقتِ ریاضی بیان کنید و از ابهام در دستورالعمل‌ها جلوگیری کنید.
### How This Grammar Works
این ساختارها در واقع یک «گیتِ منطقی» ایجاد می‌کنند که اجازه نمی‌دهد چندین عملیاتِ متناقض همزمان اجرا شوند. وقتی شما از if استفاده می‌کنید، اولین دروازه را باز کرده‌اید. اگر شرطِ داخلِ آن درست باشد، بقیه مسیر نادیده گرفته می‌شود.
این مفهوم در فارسی معادل «در صورتِ فلان، بهمان کن» است. اما نکته کلیدی در else if نهفته است؛ این عبارت فقط زمانی بررسی می‌شود که شرطِ قبلیِ if نادرست (False) بوده باشد.
در فارسی ما اغلب از «وگرنه» استفاده می‌کنیم که می‌تواند هم به معنای else باشد و هم به معنای else if، اما در انگلیسی این دو کاملاً جدا هستند. else if یک شرطِ جدید را وارد بازی می‌کند، در حالی که else یک «پناهگاهِ نهایی» است که هیچ شرطی ندارد و اگر هیچ‌کدام از حالت‌های قبلی محقق نشد، اجرا می‌شود. به عنوان مثال، در فرآیند ثبت‌نام در یک وب‌سایت: If the user is over 18, allow access; else if the user has parental consent, allow access; else, deny access.
در اینجا، اگر شرط اول برقرار باشد، سیستم دیگر وقت خود را برای بررسیِ رضایتِ والدین تلف نمی‌کند. این «کوتاه‌سازیِ مسیر» (Short-circuiting) باعث افزایش کارایی در بیان می‌شود. برای یک فارسی‌زبان، درک این نکته مهم است که else if برخلاف ifِ مستقل، به شرطِ قبلی وابسته است.
اگر شما به جای else if از چندین if جداگانه استفاده کنید، تمام شرط‌ها بررسی می‌شوند که ممکن است باعث شود چندین دستورِ متناقض همزمان اجرا شوند. این همان تفاوتِ ظریفی است که شما را از یک سطحِ متوسط (B1) به سطحِ پیشرفته‌تر در مهارتِ استدلالِ زبانی می‌رساند.
### Formation Pattern
الگوی تشکیل این جملات بستگی به زبانِ مرجع (مثلاً پایتون یا جاوا) دارد، اما منطقِ کلیِ آن در انگلیسی استاندارد به این صورت است:
| بخش | عملکرد | مثال انگلیسی |
|---|---|---|
| if | شروع شرط اصلی | If it is sunny, we go out. |
| else if | شرط جایگزین (در صورت غلط بودنِ قبلی) | Else if it is cloudy, we stay in. |
| else | حالت نهایی (اگر هیچ‌کدام نبود) | Else, we sleep. |
ساختارِ دستوری معمولاً به این شکل است:
  1. 1If (شرط اول)
  2. 2Else if / Elsif / Elif (شرط‌های بعدی)
  3. 3Else (پایان‌بخش)
نکته مهم این است که else if دو کلمه است، اما در برخی زبان‌های برنامه‌نویسی یا متون فنی خاص، از elsif (یک کلمه) یا elif (یک کلمه) استفاده می‌شود. برای مثال در زبان پایتون، elif استاندارد است، در حالی که در زبان روبی (Ruby) از elsif استفاده می‌شود. هنگام صحبت درباره این مفاهیم، باید بدانید که کدام اصطلاح در آن زمینه خاص (Context) کاربرد دارد.
### When To Use It
شما باید در شرایطی که با «انتخاب‌های انحصاری» روبرو هستید از این ساختار استفاده کنید.
اول، وقتی تنها یک انتخاب دارید: فقط از if استفاده کنید. مثلاً: If you are hungry, eat something. اینجا نیازی به else نیست.
دوم، وقتی دو انتخاب دارید: از if-else استفاده کنید. مثلاً: If the taxi is available, take it; else, walk. این یعنی یا تاکسی هست یا پیاده‌روی؛ حالت سومی در دستورالعمل شما وجود ندارد.
سوم، وقتی چندین شرطِ اولویت‌بندی شده دارید: از if-else if-else استفاده کنید. این برای زمان‌هایی است که باید یک مورد را از میان چند گزینه انتخاب کنید. مثلاً در یک مهمانی: If the guest is a vegetarian, serve salad; else if the guest is allergic to nuts, serve fruit; else, serve the main dish. در اینجا، اولویت‌بندی بسیار مهم است؛ نباید به کسی که گیاه‌خوار است، غذای اصلی داده شود.
این ساختار به شما کمک می‌کند تا اولویت‌ها را به درستی مدیریت کنید.
### Common Mistakes
  1. 1تداخلِ زبانیِ else if و else: فارسی‌زبانان اغلب از «وگرنه» برای هر دو استفاده می‌کنند. در انگلیسی، اگر از else استفاده کنید، دیگر نمی‌توانید شرطی جلوی آن بگذارید (مگر در ساختارهای خاص). اشتباه رایج این است که می‌گویند else if (condition) را فراموش می‌کنند و فقط else می‌گویند که باعث می‌شود برنامه یا کلامشان ناقص بماند.
  1. 1استفاده از ifهای مستقل به جای زنجیره شرطی: فارسی‌زبانان تمایل دارند هر شرط را به صورت یک جمله جداگانه بیان کنند. مثلاً: «اگر باران آمد چتر ببر. اگر هوا سرد شد کت بپوش.» در انگلیسی، اگر این‌ها به هم وابسته باشند، باید از else if استفاده کرد. استفاده از ifهای جداگانه باعث می‌شود هر دو شرط به صورت همزمان بررسی شوند که در منطقِ برنامه‌نویسی یک خطای فکری محسوب می‌شود.
  1. 1اشتباه در ترتیبِ اولویت‌ها: به دلیل اینکه فارسی‌زبانان در گفتگوهای روزمره تمایل دارند شرط‌های کلی را قبل از شرط‌های جزئی بیان کنند، در نوشتنِ زنجیره if-else if نیز همین کار را می‌کنند. مثلاً اول می‌گویند «اگر سن بالای ۱۸ است...» و بعد «اگر سن بالای ۱۰ است...». اگر این ترتیب رعایت نشود، شرطِ کلی (۱۸) تمامِ مواردِ جزئی (۱۰) را هم در بر می‌گیرد و شرطِ دوم هرگز اجرا نمی‌شود.
### Contrast With Similar Patterns
| ویژگی | if مستقل | if-else if زنجیره‌ای |
|---|---|---|
| عملکرد | بررسیِ تک‌تکِ شرط‌ها | توقف بعد از اولین شرطِ درست |
| انحصار | غیرانحصاری | انحصاری |
| کاربرد | برای لیست‌هایِ مستقل | برای انتخابِ یک گزینه از چند گزینه |
تفاوت اصلی در «توقف» (Short-circuiting) است. در if مستقل، تمامِ احتمالات بررسی می‌شوند، اما در زنجیره، به محضِ رسیدن به یک جوابِ مثبت، بقیه نادیده گرفته می‌شوند.
### Quick FAQ
  1. 1آیا می‌توان از else if بدون if استفاده کرد؟ خیر، هر زنجیره شرطی باید با یک if آغاز شود. else if فقط به عنوان یک ادامه دهنده تعریف می‌شود.
  1. 1تفاوت elsif و else if چیست؟ از نظر منطقی هیچ تفاوتی ندارند، اما از نظر املایی، else if دو کلمه است و در اکثر زبان‌های برنامه‌نویسی استاندارد است، در حالی که elsif یا elif کلمات اختصاری در زبان‌های خاص هستند.
  1. 1چه زمانی باید از else استفاده کنیم؟ زمانی که می‌خواهید یک حالتِ پیش‌فرض (Default) داشته باشید که اگر هیچ‌یک از شرط‌های قبلی درست نبود، آن عمل انجام شود. استفاده از آن اختیاری است اما برای کامل بودنِ منطق توصیه می‌شود.

The Logical Flow Table

Part Function Natural English Equivalent Example
If
Starts the condition
In the event that
If it rains...
Else if
Adds a second condition
But if / Or if
...else if it snows...
Else
The final alternative
Otherwise / Or else
...else, stay home.
Elsif
Technical contraction
N/A (Coding only)
elsif (x > 0)

Common Contractions and Phrases

Full Form Common Phrase Context
Or else
Do it, or else!
Warning/Threat
Else if
Or if
Conversation
If not
Unless
General usage
If so
If that is true
Confirmation

Meanings

These terms are used to create conditional sentences where an action depends on whether a specific requirement is met.

1

The Primary Condition (If)

Introduces the first requirement or possibility in a logical sequence.

“If you are hungry, we can eat now.”

“I will go if you go.”

2

The Alternative (Else)

Used to describe what happens if the 'if' condition is not met. In spoken English, often replaced by 'otherwise'.

“You must pay the fine, or else you will go to jail.”

“Eat your vegetables; else, no dessert!”

3

The Secondary Condition (Else-if)

Used when the first 'if' is false, but you want to check a second specific condition before giving up.

“If it's 10:00, I'm working; else if it's 12:00, I'm eating.”

“If the red light is on, stop; else if the yellow light is on, slow down.”

4

The Technical Contraction (Elsif)

A specific spelling used in programming languages (like Ruby or Perl) to mean 'else if'.

“The programmer used 'elsif' to save space in the code.”

“You won't find 'elsif' in a standard English dictionary.”

Reference Table

Reference table for If در مقابل Else-if در مقابل Elsif: تفاوت چیست؟
اصطلاح کاربرد زبان‌های رایج ساختار نمونه
`if`
شروع یه بلوک شرطی. همیشه چک می‌شه.
همه (JavaScript, Python, Ruby, Java, C++)
`if (x > 10)`
`else if`
یه شرط جدید رو چک می‌کنه اگه شرط قبلی `if` یا `else if` غلط بوده باشه.
JavaScript, Java, C++, C#
`else if (x > 5)`
`elsif`
یه مترادف کوتاه‌تر برای `else if`.
Ruby, Perl, Ada
`elsif x > 5`
`elif`
یه مترادف کوتاه‌تر دیگه برای `else if`.
Python, Bash scripting
`elif x > 5:`
`else`
یه بلوک 'همه‌چی‌گیر' که اگه هیچ شرط قبلی‌ای درست نبود اجرا می‌شه.
همه (JavaScript, Python, Ruby, Java, C++)
`else`

طیف رسمیت

رسمی
Should it rain, the event will be moved indoors; otherwise, it will remain outside.

Should it rain, the event will be moved indoors; otherwise, it will remain outside. (Event planning)

خنثی
If it rains, we'll go inside; else, we'll stay here.

If it rains, we'll go inside; else, we'll stay here. (Event planning)

غیر رسمی
If it rains, we're going in. If not, we're staying out.

If it rains, we're going in. If not, we're staying out. (Event planning)

عامیانه
Rain? We're inside. No rain? We're chillin' out here.

Rain? We're inside. No rain? We're chillin' out here. (Event planning)

جریان منطق شرطی

بررسی شرطی

بررسی اصلی

  • if Starts the logic

بررسی‌های بعدی

  • else if Common follow-up
  • elsif Ruby/Perl version
  • elif Python version

آخرین راه‌حل جایگزین

  • else If nothing matches

مقایسه کلمات کلیدی: `else if` در مقابل `elsif`

`else if`
Universally Understood Used in JS, Java, C++
Two Words Has a space
`elsif` / `elif`
Language Specific Ruby, Python, Perl
One Word Shorter, no space

کدوم کلمه کلیدی رو باید استفاده کنم؟

1

آیا داری یه بررسی شرطی جدید رو شروع می‌کنی؟

YES
از `if` استفاده کن
NO
برو مرحله بعد
2

آیا داری پایتون کد می‌زنی؟

YES
از `elif` استفاده کن
NO
برو مرحله بعد
3

آیا داری روبی یا پرل کد می‌زنی؟

YES
از `elsif` استفاده کن
NO
از `else if` استفاده کن

کلمات کلیدی بر اساس خانواده زبان

🔵

سبک C (JS, Java, C#)

  • if
  • else if
  • else
🟡

پایتون

  • if
  • elif
  • else
🔴

روبی و پرل

  • if
  • elsif
  • else

مثال‌ها بر اساس سطح

1

If it is cold, wear a coat.

If it is cold, wear a coat.

2

If you are happy, smile.

If you are happy, smile.

3

I will come if you ask.

I will come if you ask.

4

If I see him, I will say hello.

If I see him, I will say hello.

1

If you don't like it, don't eat it.

If you don't like it, don't eat it.

2

We can go to the park, or else we can stay here.

We can go to the park, or else we can stay here.

3

If she calls, tell me.

If she calls, tell me.

4

If it rains, we will go to the cinema.

If it rains, we will go to the cinema.

1

If the price is low, buy it; else, wait for a sale.

If the price is low, buy it; else, wait for a sale.

2

If you are tired, sleep; else if you are bored, read a book.

If you are tired, sleep; else if you are bored, read a book.

3

You must study, else you will fail the exam.

You must study, else you will fail the exam.

4

If he arrives early, wait; else if he is late, call him.

If he arrives early, wait; else if he is late, call him.

1

If the results are inconclusive, we must retest; else, we proceed.

If the results are inconclusive, we must retest; else, we proceed.

2

If you had told me, I would have helped; else, I had no idea.

If you had told me, I would have helped; else, I had no idea.

3

The software checks if the user is logged in; else if the guest mode is on, it allows access.

The software checks if the user is logged in; else if the guest mode is on, it allows access.

4

If you find any errors, please let us know; else, enjoy the book.

If you find any errors, please let us know; else, enjoy the book.

1

Should the market crash, we have a backup; else, we remain invested.

Should the market crash, we have a backup; else, we remain invested.

2

If one considers the ethical implications, the choice is clear; else, it remains a gray area.

If one considers the ethical implications, the choice is clear; else, it remains a gray area.

3

The script uses an 'elsif' ladder to handle various user inputs efficiently.

The script uses an 'elsif' ladder to handle various user inputs efficiently.

4

If the treaty is signed, peace is possible; else, conflict is inevitable.

If the treaty is signed, peace is possible; else, conflict is inevitable.

1

Were it not for his intervention, the project would have failed; else, we would be celebrating now.

Were it not for his intervention, the project would have failed; else, we would be celebrating now.

2

The linguistic distinction between 'if' and 'else' mirrors the binary nature of human decision-making.

The linguistic distinction between 'if' and 'else' mirrors the binary nature of human decision-making.

3

If the premise holds, the conclusion follows; else, the entire argument collapses.

If the premise holds, the conclusion follows; else, the entire argument collapses.

4

The code was riddled with 'elsif' statements, suggesting a lack of polymorphic design.

The code was riddled with 'elsif' statements, suggesting a lack of polymorphic design.

به‌راحتی اشتباه گرفته می‌شود

If vs. Else-if vs. Elsif: What's the Difference? در مقابل If vs. Whether

Both can introduce options, but 'whether' is for two fixed choices, while 'if' is for a condition.

If vs. Else-if vs. Elsif: What's the Difference? در مقابل Else vs. Otherwise

Learners use 'else' as a transition word, which is rare.

If vs. Else-if vs. Elsif: What's the Difference? در مقابل If vs. When

'If' is for possibility; 'when' is for certainty.

اشتباهات رایج

If it rain, I stay.

If it rains, I stay.

The 'if' clause often uses the present simple third-person 's'.

I will go if.

I will go if you go.

'If' needs a condition to follow it.

If I am happy then I smile.

If I am happy, I smile.

In modern English, 'then' is often unnecessary and can be replaced by a comma.

If it is hot? Yes.

Is it hot? If so, yes.

Don't use 'if' to ask a simple question.

If you want, else I go.

If you want, stay; otherwise, I'm going.

'Else' needs a result before it.

If it rains, or else we stay.

If it rains, we stay.

Don't mix 'if' and 'or else' in the same clause.

If I will see him, I will tell him.

If I see him, I will tell him.

Don't use 'will' in the 'if' clause.

I used elsif in my email.

I used 'or if' in my email.

'Elsif' is for coding only.

If it's red, stop, else if it's green, go.

If it's red, stop; if it's green, go.

'Else if' is grammatically correct but sounds robotic in speech.

He is coming, else?

He is coming, or what else?

'Else' cannot stand alone at the end of a question like this.

If I was you, I'd go.

If I were you, I'd go.

In formal English, use the subjunctive 'were'.

Should it rain, else we go.

Should it rain, we shall stay; otherwise, we go.

Inverted conditionals need formal balancing.

If the code has an else-if...

If the code has an 'else if'...

Even in technical writing, use the space unless referring to the keyword.

الگوهای جمله‌سازی

If it ___, I will ___.

I need to ___, else I will ___.

If you ___, then ___; else if you ___, then ___.

Should you ___, please ___.

Real World Usage

Texting constant

If u r free, let's hang. Else, ttyl!

Job Interview common

If I am hired, I will work hard; else, I will continue my search.

Ordering Food very common

If you have the vegan option, I'll take that; else, just the salad.

Travel common

If the flight is delayed, call the hotel; else, take a taxi.

Social Media occasional

If you like this post, share it! Else, just keep scrolling.

Coding constant

if (user.admin?) { show_dashboard } elsif (user.guest?) { show_welcome } else { redirect_to_login }

💡

پیش‌فرضت رو بذار روی `else if`

وقتی کلی در مورد کد حرف می‌زنی، else if رایج‌ترین و قابل فهم‌ترینه. مگه اینکه بخوای در مورد زبانی مثل روبی یا پایتون صحبت کنی.
⚠️

اشتباه نگیر `elif` و `elsif` رو!

پایتون از elif استفاده می‌کنه. روبی و پرل elsif رو به کار می‌برن. اگه اشتباهی استفاده کنی، کدت خطا می‌ده. هر دوتاشون یه کار رو می‌کنن، ولی باید مال همون زبون رو استفاده کنی.
🎯

به `switch` فکر کن

اگه کلی شرط پشت سر هم داری (مثلاً بیشتر از ۵ تا)، شاید استفاده از switch کدت رو تمیزتر و بهینه‌تر کنه. این دستور مخصوص چک کردن یه متغیر با چند تا مقدار مختلف ساخته شده.
🌍

اینا همه‌ش سلیقه‌ی زبانیه!

اینکه کدوم کلمه کلیدی استفاده بشه ( else if یا elsif یا elif) فقط یه انتخاب توی طراحی زبانه که بهش می‌گن 'قند سینتکسی'. بحث سر اینکه کدوم 'بهتره' یه گفتگوی باحال بین برنامه‌نویس‌هاست، ولی از نظر فنی هیچ‌کدوم برتری نداره.

Smart Tips

Change it to 'Otherwise'. It sounds much more natural to native ears.

Else, we can meet tomorrow. Otherwise, we can meet tomorrow.

Check if the book is about computer science. If not, it might be a typo!

He said elsif he was tired... He said that if he was tired...

Use 'Should you' instead of 'If you'.

If you need help, ask. Should you need help, please ask.

Use 'or else' at the end of the condition.

If you don't stop, I will be mad. Stop that, or else!

تلفظ

/ɪf/ you /GO/, I /STAY/

The 'If' Stress

In a conditional sentence, the stress is usually on the 'if' and the main verb of the result.

Stay (rise)... else (fall) leave.

Else Intonation

When using 'else' as an alternative, your voice usually rises on the first option and falls on the 'else' option.

The Choice Pattern

If it's A ↗️, then B ↘️.

Conveys a clear logical consequence.

حفظ کنید

روش یادسپاری

IF starts the car, ELSE IF changes gears, and ELSE is the parking brake.

تداعی تصویری

Imagine a traffic light. IF it's red, stop. ELSE IF it's yellow, slow down. ELSE (it must be green), go!

Rhyme

If for one, Else if for two, Else for when you're finally through.

Story

A traveler reaches a bridge. IF he has a coin, he crosses. ELSE IF he has a sword, he fights. ELSE, he turns back home.

شبکه واژگان

IfElseElse-ifOtherwiseUnlessConditionResult

چالش

Write a 3-step instruction for making coffee using If, Else if, and Else.

نکات فرهنگی

In Silicon Valley and tech hubs, 'if-else' logic is often used as a metaphor for life decisions.

British speakers often use 'otherwise' or 'or else' more frequently than 'else' in casual conversation.

Legal documents use 'if' and 'else' (often as 'failing which') to create airtight contracts.

'If' comes from the Old English 'gif', meaning 'given that'. 'Else' comes from 'elles', meaning 'other'.

شروع‌کننده‌های مکالمه

If you could travel anywhere right now, where would you go?

If it rains this weekend, what are your backup plans?

What happens if you forget your keys?

If you were the president, what is the first law you would change?

موضوعات نگارش

Write about your morning routine using at least three 'if' statements.
Describe a difficult decision you made. Use 'if', 'else if', and 'otherwise'.
Imagine a world where it never rains. How would life be different? Use 'if' and 'else'.
Write a set of instructions for a robot to make a sandwich.

اشتباهات رایج

Incorrect

صحیح


Incorrect

صحیح


Incorrect

صحیح


Incorrect

صحیح

Test Yourself

کلمه کلیدی درست رو برای یه بلوک کد جاوااسکریپت انتخاب کن.

if (score > 90) { grade = 'A'; } ___ (score > 80) { grade = 'B'; }

✓ Correct! ✗ Not quite. Correct answer: else if
جاوااسکریپت، مثل جاوا و C++، از else if دو کلمه‌ای برای چک کردن شرط‌های بعدی استفاده می‌کنه.
کدوم جمله به درستی کلمه کلیدی رو برای پایتون توصیف می‌کنه؟ چند گزینه‌ای

جمله درست رو انتخاب کن:

✓ Correct! ✗ Not quite. Correct answer: پایتون برای شرط‌های اضافی از `elif` استفاده می‌کنه.
elif کلمه کلیدی مخصوص پایتونه که به عنوان مخفف 'else if' به کار می‌ره.
اشتباه رو در این جمله در مورد روبی پیدا و اصلاح کن. Error Correction

Find and fix the mistake:

برای اضافه کردن یه چک دیگه در روبی، از کلمه کلیدی `else if` استفاده می‌کنی.

✓ Correct! ✗ Not quite. Correct answer: برای اضافه کردن یه چک دیگه در روبی، از کلمه کلیدی `elsif` استفاده می‌کنی.
روبی یکی از زبان‌های خاصیه که از مخفف elsif استفاده می‌کنه.

Score: /3

تمرین‌های عملی

8 exercises
Choose the correct word to complete the sentence. چند گزینه‌ای

If you are tired, go to bed; ___, you will be grumpy tomorrow.

✓ Correct! ✗ Not quite. Correct answer: else
'Else' provides the alternative result.
Fill in the blank with 'if', 'else', or 'else if'.

___ it is 5 PM, I leave work; ___ it is 6 PM, I am at the gym.

✓ Correct! ✗ Not quite. Correct answer: If / else if
The first starts the condition, the second adds another specific one.
Correct the error in this sentence. Error Correction

Find and fix the mistake:

If I will see her, I will tell her.

✓ Correct! ✗ Not quite. Correct answer: If I see her
We don't use 'will' in the 'if' clause.
Match the condition to the result. جفت کردن

1. If it's hot... 2. Else if it's cold... 3. Else...

✓ Correct! ✗ Not quite. Correct answer: 1-B, 2-A, 3-C
Matching logical conditions to appropriate actions.
Put the words in the correct order. Sentence Reorder

else / study / you / will / fail / hard

✓ Correct! ✗ Not quite. Correct answer: Study hard, else you will fail.
The command comes first, followed by the 'else' alternative.
Is this rule true or false? True False Rule

You can use 'elsif' in a formal business letter.

✓ Correct! ✗ Not quite. Correct answer: False
'Elsif' is a programming keyword, not a standard English word.
Complete the dialogue. Dialogue Completion

A: Are you coming to the party? B: If I finish my work, yes; ___, I'll have to stay home.

✓ Correct! ✗ Not quite. Correct answer: else
'Else' shows the alternative to finishing work.
Rewrite the sentence using 'if'. Sentence Transformation

Stay here or you will get wet.

✓ Correct! ✗ Not quite. Correct answer: If you don't stay here, you will get wet.
The 'or' structure can be transformed into a negative 'if' condition.

Score: /8

Practice Bank

14 exercises
جمله رو با اصطلاح درست کامل کن. پر کردن جای خالی

من دارم روبی کد می‌زنم، پس باید به جای `else if` از ___ استفاده کنم.

✓ Correct! ✗ Not quite. Correct answer: elsif
کدوم جمله برای یه برنامه‌نویس C++ درسته؟ چند گزینه‌ای

جمله درست رو انتخاب کن:

✓ Correct! ✗ Not quite. Correct answer: در C++، `else if` استاندارد برای چک کردن یه شرط دیگه است.
اشتباه رو در نظر برنامه‌نویس پیدا و اصلاح کن. Error Correction

کد پایتون من خراب شده. دستور `elsif` باعث خطای سینتکسی شده.

✓ Correct! ✗ Not quite. Correct answer: کد پایتون من خراب شده. دستور `elif` باعث خطای سینتکسی شده.
کلمه کلیدی درست رو برای پایتون انتخاب کن. پر کردن جای خالی

کد چک می‌کنه `if user_type == 'admin':`، و بعد `___ user_type == 'editor':`

✓ Correct! ✗ Not quite. Correct answer: elif
هر زبان برنامه‌نویسی رو با کلمه کلیدی درستش تطبیق بده. جفت کردن

زبان رو با کلمه کلیدی 'else if' خودش تطبیق بده:

✓ Correct! ✗ Not quite. Correct answer: matched
مفهوم رو به یه جمله انگلیسی درست ترجمه کن. ترجمه

در زمینه برنامه‌نویسی، عمومی‌ترین و قابل فهم‌ترین اصطلاح برای یه چک شرطی که بعد از 'if' میاد چیه؟

✓ Correct! ✗ Not quite. Correct answer: ["The most generic term is else if.","It's generally called an else if statement."]
کلمات رو به ترتیب بچین تا یه گزاره درست بسازی. Sentence Reorder

این کلمات رو به ترتیب بچین تا یه جمله درست بسازی:

✓ Correct! ✗ Not quite. Correct answer: `elsif` is Ruby's shorthand for `else if`
کدوم یکی از این گزاره‌ها همیشه درسته؟ چند گزینه‌ای

کدوم جمله درست؟

✓ Correct! ✗ Not quite. Correct answer: همه زبان‌ها از `if` برای شروع یه شرط استفاده می‌کنن.
اشتباه رو در جمله پیدا و اصلاح کن. Error Correction

استفاده از `elif` در یه فایل جاوااسکریپت یه عمل رایجه.

✓ Correct! ✗ Not quite. Correct answer: استفاده از `else if` در یه فایل جاوااسکریپت یه عمل رایجه.
Put the words in order to form a correct rule. Sentence Reorder

Arrange these words into a sentence:

✓ Correct! ✗ Not quite. Correct answer: You must use `elif` when coding in Python.
Match the term to its description. جفت کردن

Match the conditional term to its role:

✓ Correct! ✗ Not quite. Correct answer: matched
Type the correct English sentence. ترجمه

What is the primary reason for a language to use `elsif` instead of `else if`?

✓ Correct! ✗ Not quite. Correct answer: ["It's mainly for brevity and developer convenience.","The main reason is for conciseness.","It's a stylistic choice for making code shorter."]
فرایند فکری توسعه‌دهنده رو کامل کن. پر کردن جای خالی

باشه، چک اول `if (is_ready)` هست. چک بعدی باید `___ (is_waiting)` باشه چون من دارم جاوا کد می‌زنم.

✓ Correct! ✗ Not quite. Correct answer: else if
Find and fix the mistake in this sentence. Error Correction

The main difference between `if` and `else if` is that `if` is optional.

✓ Correct! ✗ Not quite. Correct answer: The main difference between `if` and `else if` is that `else if` is optional.

Score: /14

سوالات متداول (8)

In English, no. In programming languages like Ruby, yes. In writing, always use 'else if' or 'or if'.

Rarely. It usually follows a comma or a semicolon. Use 'Otherwise' to start a new sentence.

'Unless' means 'if not'. 'Unless it rains' is the same as 'If it doesn't rain'.

Only if the 'if' clause comes at the beginning of the sentence.

It can be! If you don't finish the sentence, it sounds like a threat. 'Do it, or else!'

Yes! 'Who else is coming?' or 'What else do you need?' are very common.

It's a shortcut to save typing and make the code run slightly faster in some older languages.

It's when you put an 'if' inside another 'if'. 'If it's Monday, then if it's raining, I stay home.'

Scaffolded Practice

1

1

2

2

3

3

4

4

Mastery Progress

Needs Practice

Improving

Strong

Mastered

In Other Languages

Spanish high

si / sino / o si no

Spanish has a specific word 'sino' for 'else' when it means 'but instead'.

French high

si / sinon

French 'si' can also mean 'yes' in response to a negative question, which 'if' cannot do.

German moderate

wenn / falls / sonst

German uses 'wenn' for both 'if' and 'when', which is a major point of confusion for learners.

Japanese low

moshi / nara / tara

Japanese conditionals are built into the verb conjugation, not just placed at the start of the sentence.

Arabic moderate

in / idha / law

English uses 'if' for all three, relying on verb tenses to show the difference.

Chinese moderate

rúguǒ / yàobù

Chinese often omits the 'if' word entirely if the context is clear.

Learning Path

Prerequisites

Was this helpful?
هنوز نظری وجود ندارد. اولین نفری باشید که افکار خود را به اشتراک می‌گذارد!