Post 'em.
>>60339344
kys
What the fuck does "be awesome" mean?
If you're sad for whatever reason, you can't just turn off emotion, you stupid shit.
>>60339362
it's a
>just beeee urself
in "nerd" language
>>60339344
gay as fuck desu famalam.
>>60339344
Cringe
>function().function()
really makes you think
>>60339399
>>60339344
This picture can fuck right off. OP, are you 12 years old? No self respecting human being over the age of 12 would save this on their computer.
>>60339344
Javascript is so shit you need a TYPE COERCIVE EQUALITY OPERATOR.
Also what the fuck kind of object is also a function?
>>60339419
>computer
:^)
>>60339344
>beawesome()
>while writing in javascript
webdevs have no self-awareness
>>60339344
i don't think boolean true has a method called stop
>>60339417
>>60339408
>>60339362
>you can't just turn off emotion
You can.
>>60339529
This anon is correct, just kys that turns off all emotion :^)
>>60339344
Is that Perl?
>>60339344
if(!isPooInLoo){
getLoo();
pooInLoo();
}
>>60339344
>===
?
>>60339416
I mean, chaining functions is nothing extraordinary, you're calling the second function on the return value of the first function. Except we've already established that the return value of sad() is true, so we're calling true.stop()
So the core message of this picture is that sad people should flee the truths that are too painful for them to bear and find refuge in a comforting lie. Really makes you think.
>sad is a function
>we don't know if it returns anything
>calling a function on a function call
>calling a function on a Boolean instead of setting it to false
Who else but jsdevs
>>60339344
>camelCase
Yuck.
>>60339344
go back to facebook faggot
I can only compile lisp please rewrite it
>>60340166
Or maybe sad() returns an object and === operator is overloaded so it will work with booleans?
>>60340521
In all languages I've seen it in, === is the identity operator. That would mean the return value of sad isn't just truthy, it actually is the boolean true.
>>60339425
>he doesn't know about data abstraction
>>60339344
How can sad() return true and then return an object that has a stop function? I would by this shirt if it was
if (self.sad?() === true) {
self.emotion = happy;
self.beAwesome();
}
>>60340704
simple minded.
>>60339344if (sad.toBoolean()) {
ftfy
>>60340704
sad() returns an object that can be casted to bool
>>60340795
sad() has a side effect where on even even calls it returns a boolean and on odd calls it returns an object.
>>60339471
Yes but you can still add it to true's prototype.
/g/-chan daisuki
>>60340862
lmaoing@your life
>untyped language
no wonder JS programmers are sad
>>60339992
likely javascript equal operator
compares type and value so sad() returns a boolean true, instead of any other 'true' value, int 1 for example
>===
fuck off with your pleb language
>>60339436
For all intents and purposes, your phone is a computer. Also your psp, your ipod and whatever. Even if you've grabbed an Ethernet cable and are using it to communicate with the 4chan servers, your brain is a computer and you saved the image by memorizing it
>>60339362
>you can't just turn off emotion
step up senpai
[/code]
#include <stdio.h>
int main(void)
{
printf("epic post op!! upvoted.\n");
return 0;
}
[/code]
>>60339344
>>>/reddit/
LOL
>>60339344
>>60343356
lol where did you guys find this im laughing my ass off XD.
>>60343356
At least this follows the noun.verb() bullshit you're supposed to be following in OOP
>>60339344
>2017
>Using if statements
>>60343356
What if your boss isn't called Nearby?
>>60339344
go back to plebbit
That isn't even proper pseudocode
Fuck off you webdev scum
>>60340521
=== matches type, so sad() would HAVE to return a boolean.
But it's irrelevant, because any truthy result would satisfy the conditional so having == true is unnecessary.
>>60339344
cool dobs opimport human;
// import physical_utilities.items.weapons;
Human me = get_current();
if(me is null)
return;
else {
me.brain.Emotion sad_emotion = me.brain.emotions.get_node_by_tag("sadness");
if(sad_emotion.value > sad_emotion.THRESHOLD_KS)
sad_emotion.value = sad_emotion.value - sad_emotion.time_delta;
else {
me.brain.Action ks_action = me.brain.motive.get_node_by_tag("KS");
ks_action.initialize;
while(!ks_action.ready){
// err: access violation here for some reason
writefln("time %d id %d", current_time, me.id);
ks_action.update;
yield;
}
ks_action.execute;
me.valid = false;
destroy(me);
return;
}
}
>>60339344
>Boolean getter method is not prefixed with get or is
>Some shitty scripting language where == d
>Comparing to true
>Member function of a boolean ???
>No newline before curly brace
>>60339408
sauce?
>>60339344
are you supposed to use === for everything? what is the point of ==?
>>60346558
So you can do stupid shit like this."0.0" == false
>>60339344
You can tell this was written by a fucking woman.
>>60346515
>method
It's a simple if statement, you colossal sperg.
>>60339344
JavaScript is trwtf, but even in that lovecraftian language shit like this isn't logical code. Ether the condition isn't satisfied, or evaluation of sad().stop(); results in a type error (sad.stop is not a function).
You can never be awesome. There's some reality for ya.
>>60340521
That doesn't work in JavaScript.
However, you can actually make the code valid by adding a stop function to the prototype of the boolean constructor.Boolean.prototype.stop = function() { console.log("Stop called!") };
var a = false;
a.stop();
//Stop called!
>>60347076
To further elaborate on this and to BTFO the fizzbuzz armchair programmers on this board who will never be able to get a programming job, here:function beAwesome() {
console.log("BeAwesome Called");
}
var _sad = true;
function sad() {
return _sad;
}
window.Boolean.prototype.stop = function() {
_sad = false;
};
// The actual code
if (sad() === true) {
sad().stop();
beAwesome();
}
That runs. Fuck you. Learn JavaScript before you make ridiculous claims like "it doesn't run".
But don't get me wrong, this code is still stupid as fuck.
>>60347076
>>60347240
Goddamn I hate Javascript.
>>60347319
Why? What about this code is unclear?
>>60347340
It's clear that it does work, and it's clear how it works. I just hate that it does.
As much as it can be, anyway. I still don't
really understand how prototypal inheritance works.
Anyone else get triggered by pseudocode?
It's just so dumb and not funny.
>>60347462
Pseudocode is fine.
Pseudocode masquerading as code like OP is just retarded and I hate it.
>>60347401
Prototypical inheritance isn't nearly as hard as people think it is. Maybe I can help you a little.
Let's just say you have this object:var a = {
prop: 'Hi!',
otherProp: 'sup!'
};
Now, when you doa.prop or a.otherprop, you can access its members.
What if we saya.thirdProp? That doesn't exist on a, so we get undefined.
Now let's add prototypes into the mix.
Every object has a special property called __proto__. Let's create another object and assign it as a's __proto__:var b = {
thirdProp = 'Hi again!'
}
a.__proto__ = b;
And let's calla.thirdPropagain. Instead of getting undefined, we actually get 'Hi again!' this time.
What happened? Well, when we dida.thirdProp, the code first checked if a has this member. It doesn't. But instead of returning undefined here, it went to look at a's __proto__. Does its __proto__, which we set to be b have the property thirdProp? Yes it has. So that's what it returned.
If a had a property called thirdProp by itself, the prototype wouldn't have been looked at and the property value from a would be returned. If b didn't have a thirdProp, then the engine would have looked at b's prototype and, then at b's prototype's prototype and so on until one of the objects in this so-called "prototype chain" has no __proto__.
things like a.ToString() or a.valueOf() for example, also come from this prototype chain. Unless you explicitly say not to, all objects have an "Object" instance as their prototype, which has these properties.
So in essence, it's simple. "Does my object have the requested property? If no, ask its __proto__. Otherwise, ask __proto__ of its __proto__. Keep going until one of the __proto__s has the property or until we have no more __proto__ in the chain.
>>60347967
I already knew that much, yeah. Your prototype is just another object and it works pretty much like a superclass.
But then you introduce the new keyword and these pseudo-constructors and I'm lost all over again.
>>60348047
Yeah.The confusing part of this is that there is __proto__ and prototype. JS developers refer to both as "Prototype", even though they are really different.
Basically, Functions in JavaScript are somewhat special. Like all objects, they have a __proto__, which is the function object which gives your functions methods like call, bind, name etc.
But all functions also have a property called prototype, which is separate from __proto__. By default, a function's prototype property is (almost) an empty object.
This prototype object doesn't change the behavior of the function itself in any way. It only gets used when you use the "new" operator. The new operator can be used on any function to produce an object that is an instance of this function, for example:var fun = function() {};
var funOb = new fun();
funOb instanceof fun; // returns true.
When we call new, the function gets executed with the variable "this" being set to the new objects that's getting constructed. For example, we can add properties to it here.var fun = function() {
this.someProperty = 'Hello!';
};
var funOb = new fun();
funOb.someProperty; // Returns 'Hello!'
Guess that's not that weird until now.
What may be weird to you is that funOb has a __proto__. Not just the default Object, but... fun.prototype.
That means that when we add a property to fun.prototype, we add the property to the __proto__ of any instance of fun we create.
So for example, when we dofun.prototype.doSomething = function() {
console.log("Doing Something!");
};
, we can dofunObj.doSomething();.
The normal prototype chain shit happens then. funObj checks if it has a property called doSomething. it doesn't. So it checks its __proto__. Its proto is fun.prototype. fun.prototype DOES have the property doSomething, we just added it. So that gets returned (and is then called).
Hope this is understandable.
>>60348349
Thanks for bearing with me. This is very confusing stuff.
>>60348349
And that's pretty much how the code I made earlier with the window.Boolean.stop work.
When you create a boolean, even though you don't use new, it works the same. There is a function on the window object called Boolean. Because it is a function, it has a property called prototype.
So when a bool is created, the booleans __proto__ is automatically set to window.Boolean.protoype. You can actually confirm this if you dotrue.__proto__ === window.Boolean.prototype; //true
So when I defined window.Boolean.prototype.stop, any boolean could use that "method" now, because it's in its __proto__.
>>60348489
Yeah. It is. The naming really sucks and that's the biggest problem if you ask me.
>>60339358
that's very inspirational
>>60340917
>Hey man I added a stop() method to booleans.
>Cool what does it do
>Is makes the booleans stop hitting me.
>implying you can just stop being sad
Yeah tell that to all the depressed people.
>>60339408
I-I want to look cute like that...
>>60347424
HTML IS NOT A PROGRAMMING LANGUAGE!!!
>>60343356
If should be something like thisif (Boss.getLocationMath <= you.getLocationMath)
do.work();
else
do.videogames();
>>60351151
>writing code on phone
> [>_<]