+ 10

Is there an equivalent to python exec() in ruby?

Since I failed writing a brainfuck interpreter in python and writing a compiler would be too complicated because of loops, indents and stuff, I decided to do it in ruby, where you use the end keyword to end loops. I made a program that already turns bf code into ruby code, now I only need some function to execute it.

21st Apr 2017, 3:22 PM
Supersebi3
Supersebi3 - avatar
3 Réponses
+ 8
Found it, its just exec, but now it says permission denied... why?
21st Apr 2017, 5:55 PM
Supersebi3
Supersebi3 - avatar
+ 2
I do not know much about the Ruby eval statement, but I think it's what you're looking for. If your code is a string, then do eval "lambda { " + your_string + " }" And then you can run that lambda to run your code. sources: https://stackoverflow.com/questions/2459170/create-a-ruby-proc-from-a-string I think the Ruby exec() is actually the equivalent of Python's import os os.system() and lots of times you need permission before running shell commands (I'm really familiar with the Python exec() function but I'm still learning Ruby)
7th Dec 2017, 5:15 AM
Jeff Hykin
Jeff Hykin - avatar
+ 1
@Jeff Hykin late answer, im not using ruby anymore, thanks anyways
7th Dec 2017, 5:24 AM
Supersebi3
Supersebi3 - avatar