Add support for new variadic slot features. --MF, 2/1/22
plural
block accept a word as input, join a letter "s" to the end, and report the new, plural word as output.
Hat blocks tell you when a piece of code should be run and what (if any) inputs it takes.
This code will run whenever the plural
block is called, and takes one input called word.
plural
hat block, and click the plus sign that appears.plural
block.
join
block out of the palette on the left and into the report
block.plural
hat block, drop it into the first input slot of join
, type an "s" in the second slot, and press "OK." Whatever text is typed into the word input slot of plural
will be the first input to join
.plural of
block out of the palette (it'll be at the bottom of the Operators category) into the Scripts area, and test it with different inputs. (For example, if you give it the input "cat," it should report, "cats.") If there are any problems with your block, right-click it, select "edit..." and make sure your code looks like this:plural
block is working, try it with random animal
, and finally, drag super short story
, and make sure it works as expected.plural
block works for more than just animals! Try it with the random job
block. Will they be watching a video on abstraction here? Or does Dan mention it in welcome? It feels so..abstract..here that I wonder what students will take from it. If I wasn't bound to use the term abstraction, I'd probably emphasize the benefit of reuse "When we realize we've developed a useful piece of functionality that we might want to use in other places, we can turn it into its own block." Anyway just musings from your local "abstraction" skeptic, feel free to delete. -- PF 8/20/21
I added your text at the beginning and am open to a Dan video and/or more discussion about teaching abstraction. :) --MF, 8/20/21
When you've developed a useful piece of code that you want to use in other places, you can turn it into its own block. This is a form of abstraction. Abstraction is an important idea in computer science. One kind of abstraction is breaking up a large problem into smaller sub-problems.
super short story
, you can create a random animal
in its input slot.This makes your code easier to read, you can use the new block again in other places, and once the block is working, you don't need to think about how it works each time you use it.