Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A void method that returns a value? How on earth did this coffeeshop compile?


A void method that returns a sandwich, no less.


Requires root user to run


'sudo make me a sandwich'


    -bash: sudo make me a sandwich: command not found


I'm surprised you don't have make installed. That's usually one of the first tools I install on any new system (if it's not included as part of the base install, like Arch does):

    sudo apt-get install build-essential
Incidentally, the make error you'd get is amusing:

    make: *** No rule to make target `me'.  Stop.


    sudo make me a sandwich
will result in sudo running with 'make me a sandwich' as arguments.

    'sudo make me a sandwich'
will result in 'sudo make me a sandwich' running.


Ah, yes. I didn't spot the quotations encapsulating the code in the parent post. That will teach me to skim-read jokes.


I like hilariously meta jokes.


Maybe sudo is not installed?


    sudo pacman -S make
    curl https://put.honkgong.info/ed8e3df8691ec7944a878cea595e00c363079504 > Makefile
    sudo make me a sandwich


Let's run arbitrary code downloaded from somewhere I don't know! As root!


Did you read the linked Makefile?


1. The posted code could change between when you read it and when I read it.

2. If you just cut-and-paste these three lines, then you are obviously not reading it.


That's why you have another line saying something like:

    cat Makefile
before blindly executing it. In general, you shouldn't blindly believe downloaded code, but in this case Makefile is simple enough that you can prove it's non harmful in a few second glance.


ok


Never mind that the function casts (coerces? constructs?) ints to bread and ints to bacon. Let alone how it's got a special "plus" operator that can work on bread/bacon and return a sandwich...


If you look carefully at the screenshot, you'll see that bread and bacon are declared to be ints above the method. =]


Clearly bad practice to be using raw integers here. They should at least be using enums.

public enum Ingredients { BREAD, BACON }

public enum Delicatessen { BACON_SANDWICH }


Hopefully they'll fix this in the next GTA patch.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: