From Test-Scratch-Wiki

Replace Item () of () with ()
replace item () of [ v] with ()
Category वैरिएबल
Type स्टैक ब्लॉक
Introduced in स्क्रैच १.३

() की () चीज़ को () से बदलें ब्लॉक एक लिस्ट ब्लॉक है और एक स्टैक ब्लॉक है। यह ब्लॉक बताई गई वस्तु को अंतिम इनपुट से बदल देता है। स्क्रैच १.३ में इसे पेश किया गया था।

उदाहरण उपयोग

इस ब्लॉक के कुछ सामान्य उपयोग हैं-

  • एक वस्तु को बदलना (उदाहरण के लिए, एक सूची में एक वस्तु को किसी दूसरी वस्तु से बदलना)
ask [What item would you like to change in the grocery list?] and wait
set [item v] to (answer)
ask [What would you like to change it to?] and wait
set [new food v] to (answer)
replace item (item) of [grocery list v] with (new food)
  • बिना वस्तुओं को हटाए, लिस्ट को रिराइट करना
say [Oops, I got the wrong grocery list! I need to get a new one.] for (3) seconds
set [item v] to (0)
repeat (length of [grocery list v])
    change [item v] by (1)
    replace item (item) of [grocery list v] with (item (pick random (1) to (5)) of [Foods v])
end
  • कुछ आंकड़ों के रिकॉर्ड को बदल देने के लिए
say [And Mike crosses the finish line! This is a new record for the 100 meter relay!] for (4) seconds
replace item [5] of [school records v] with (relay time)
  • एक पहले-से ही मौजूद वस्तु में वर्णों को जोड़ना
replace item [1] of [list v] with (join (item [1] of [list v]) (. )) //"कैरेक्टर्स" नए अक्षर हैं
  • अलग-अलग क्लोन्स के वर्तमान स्थान को रिकॉर्ड करने के लिए
when I start as a clone
set [id v] to (total clones)
add [] to [clonesX v]
forever
    if <key (left arrow v) pressed?> then
        change x by (-2.5)
    end
    if <key (right arrow v) pressed?> then
        change x by (2.5)
    end
    replace item (id) of [clonesX v] with (x position)
end

दूसरा तरीका

इस ब्लॉक को रेप्लिकेट करने का तरीका है-

delete (item) of [list v]
insert (. . .::grey) at (item) of [list v]

संदर्भ

Cookies help us deliver our services. By using our services, you agree to our use of cookies.