.
Attached: if.png?fit=300%2C221.png (300x221, 6K)
.
Other urls found in this thread:
github.com
twitter.com
>$ is a condition
fucking capitalist pig
!!$condition is better.
>weak typing
pig disgusting
if (condition == true)
{
return true;
}
else if (condition == false)
{
return false;
}
if (condition == true and condition != false)
{
return true;
}
else if (condition == false and condition != true)
{
return false;
}
//else return 5 because im so random yay :D
else
{
return 5;
}
This is triggering me way too much
bool isCondition(bool condition) {
return condition;
}
else {
throw new Exception();
}
Oh this is good
*revolves fedora*
wtf is wrong with you guys. if condition is a bool just do
return condition;
gotta check if its either true or false first though
How do we know if it's true or false though? Huh?
Nice! I think we could also add a null check before the test, and perhaps wrap that logic inside its own class (BooleanTester) and perhaps even package that to be re-used by other developers
.You have so much stuff to learn.
kek
if !condition == false {
return true
} else {
return false
}
ugly braces
sorry the compiler complain when I remove them or when I don't use the exact indentation they want
if (str(int(condition)) == "1" and str(int(condition)) != "0")
{
if str(int(DoubleCheckBool(str(int(condition))))) == "1"
{
return [true,"this variable is true"];
}
else
{
return [false,"this variable is false"];
}
}
else if (str(int(condition)) == "0" and str(int(condition)) != "1")
{
if str(int(DoubleCheckBool(str(int(condition))))) == "0"
{
return [false,"this variable is false"];
}
else
{
return [true,"this variable is true"];
}
}
//else return 5 because im so random yay :D
else
{
return 5;
}
atleast make it readable
public class BooleanTester
{
private Boolean m_Condition;
public BooleanTester(final Boolean condition)
{
m_Condition = condition;
}
public BooleanTester()
{
m_Condition = true;
}
public Boolean getCondition()
{
return m_Condition;
}
public void setCondition(final Boolean condition)
{
m_Condition = condition;
}
public Boolean testCondition()
{
if (m_Condition == null) throw new NullPointerException();
if (m_Condition == true)
{
return new Boolean(true);
}
else if (m_Condition == false)
{
return new Boolean(false);
}
else
{
throw new Exception();
}
}
}
Here's a first draft. I think we could make the class generic, in case we want to use different types of boolean objects. Like a void-safe MaybeBoolean that may not be false or true, but not necessarily null either.
>m_Condition
what's the point in this fugly style
if you actually care about pointing out something is a member then prefix everything with this
>no factory
>no abstraction
>not thread-safe
>no callbacks
Well, "m_" is shorter than "this->", but I agree it's fugly. I'd prefer "Condition_", but I don't program sepples.
You can do still do
this.m_Condition
There is a no consideration for safety at all in this thread. At very least use pre and post conditions on your boolean functions guys.
--TOFIX
--UNIT TESTS FOR isBoolean and isCondition
--Helper function to use in the contracts for isCondition
function isBoolean(B : in Boolean) return Boolean is
begin
if B = True or B = False then
return True;
else
return False;
end if;
end isBoolean;
function isCondition(B : in Boolean) return Boolean
with
Pre => isBoolean(B), --Verifies if input is a Boolean
Post => isBoolean(isCondition'Result) --Verifies if return value is Boolean
is
begin
if B = True and then B /= False then
return True;
elsif B = False and then B /= True then
return False;
else
raise Program_Error; --You never know
end if;
end isCondition;
function function(string) {
var str = string
if (str.length === '0' || str.length === 0 || str.length == 0) {
return false }
else {
return true }
}
Making some progress, but we're still missing:
1. Any sort of logging
2. Documentation
3. Ability to configure the test (sometimes, we might want to invert the test to actually return false when it's true, and true when it's false)
OP? Fag : Straight
Now post this shit in assembly code
return condition ? true : false;
>untyped language
I like where this thread is going
public static void main() {
boolean boovar = true;
System.out.println("Your boolean value is set to " + String.valueOf(boovar) + ".");
}
// Hey guys :D
// Hope you're enjoying my code
// This is a simple (else) if statement, to check whether a condition is true or not
// if it's true, it will return true
// if it's false, it will return false
// if you have any questions, feel free to contact me on facebook. I promise I won't bite XD
// Here it goes!
// check if the condition is true
if (condition == true)
{
// make sure the condition is true, by checking if it's not false
// always be safe :)
// != means not equal fyi ;)
if (condition != false)
{
// create boolean x
// a boolean can be true or false
bool x;
// set x to true, because the condition is true
x = true;
// return x, which is true
return x;
}
}
// check if the condition is false
// only checks, if the condition isn't true
// after all, we want our code to be optimized :)
else if (condition == false)
{
// make sure the condition is false, by checking if it's not true
if (condition != true)
{
// create boolean y
// be sure to use another letter
// we don't want others to mix it up with x
bool y;
// set y to false, because the condition is false
y = false;
// return y, which is false
return y;
}
}
Thanks, mom.
>Pull request rejected
>Reason: insufficient commentary
For JavaScript I like
if(typeof something !== "undefined" && something === true) {
return true;
}
return false;
More like
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
return y;
}
if condition == True:
return True
else:
return False
bool is_true(T condition) {
auto just_guess = std::bind(std::uniform_int_distribution(0,1), std::default_random_engine());
return just_guess();
}
>Implying every language has booleans
>Implying only booleans can == true/false
Get gud
is there a true/false that is like "sorta true" or "sorta false"
you could use doubles in the range [-1.0, 1.0]
positive values are sorta true. negative values are sorta false.
falsey and truthy
eg. 0 == "0" is truthy because they equal but aren't the same type