LESSON 07 OF 52 · CHAPTER 01

String Bindings

Reassigning a string and local shadowing

ORIGINAL SOURCE

07-string-bindings.srp

var greeting = "Hello from Scarp!";
bind original = greeting;
print(greeting);
greeting = "नमस्ते 🌍";
{
    bind greeting = 42;
    print(greeting);
}
print(original);
print(greeting);
EXPECTED OUTPUT

stdout

Verified
Hello from Scarp!
42
Hello from Scarp!
नमस्ते 🌍

UNDERSTAND THE CODE

Explanation & practice

What this example teaches

Reassigning a string and local shadowing

Expected behavior

English and Hindi text, plus integer 42

Practice: Read the source before looking at the output. Predict the values and their order, then use the pinned compiler to execute this lesson and compare the exact fixture. Identify which operation produces the result.

स्ट्रिंग और स्थानीय नाम

UTF-8 स्ट्रिंग में देवनागरी और इमोजी हो सकते हैं। var greeting बदलता है, जबकि भीतर bind greeting = 42 एक अलग स्थानीय नाम है।

अभ्यास: स्थानीय स्कोप समाप्त होने पर greeting का मान क्या है?

Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.

TRY IT LOCALLY

Verify, then execute

Use the pinned compiler from the course root. Keep any imported _support files next to the source.

scarp verify examples/01-basics/07-string-bindings.srp scarp exec examples/01-basics/07-string-bindings.srp

The website does not run code. Read the CLI guide ↗

Pinned compiler: Scarp v0.0.6-alpha.3 · ceff07d9014f. No simulated output.