LEGO® Answers is a question and answer site for LEGO® and building block enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Imagine I create a MyBlock called "function1" from a line of blocks. Can I call that block from within itself?


This is the program for the block "recursiveTest."

Will this block function properly?

share|improve this question

No, EV3 MyBlocks cannot be recursive. If a MyBlock contains a copy of itself, then the following error will be produced upon compiling:

The error produced when trying to put a MyBlock inside a MyBlock

For some reason, LEGO's programming software has become progressively less immediate about notifying you that this cannot be done. In EV3-G, it waits until compile to let you know that you can't do this. In NXT-G (the software for programming the NXT), trying to put a MyBlock in itself produces an error upon placing it. And in the Robotics Invention System 2.0 (the software for programming the RCX), it simply won't let go of the MyBlock you're dragging if you try and place it into itself.

If you want a programming language for the EV3 that supports recursion, I'd like to offer LeJOS EV3 (Java-based, free) and ROBOTC (C-based, costs money) as alternatives. They're both EV3-compatible, and support recursion.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.