if ( x == true)
{
// do something
}
Fucking amateurs :| lol
function isAllowSearchLength(text) {
return text.length > isNaN(parseInt(text, 10)) ? 1 : 0;
}
public class SentCon3 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double input;
char choice;
System.out.println("**** Menu-Driven Temperature Converter*****");
System.out.println("only lowwer case is vaild");
System.out.print("Enter the value to beconverted==> ");
input = scan.nextDouble();
System.out.println("What is your choice?");
System.out.println("a)Fahrenheit to Celsius");
System.out.println("b)Celsius to Fahrenheit");
System.out.println("c)Kelvin to Celsius");
System.out.println("d)Celsius to Kelvin");
System.out.println("e)Kelvin to Fahrenheit");
System.out.println("f)Fahrenheit to Kelvin.");
System.out.print("Please enter your choice ==>");
choice = scan.next().charAt(0);
while (choice == 'a') {
System.out.println((input / 5) * 9 + 32);
break;
}
while (choice == 'b') {
System.out.println((input - 32) * 5 / 9);
break;
}
while (choice == 'c') {
System.out.println(input - 273.15);
break;
}
while (choice == 'd') {
System.out.println(input + 273.15);
break;
}
while (choice == 'e') {
System.out.println((input - 273.5) * 9 / 5 + 32);
break;
}
while (choice == 'f') {
System.out.println((input + 459.67) * 5 / 9);
break;
}
}
}
use while as if!!!!
function IsAOrB(const p_Id: string): boolean;
begin
if ((p_Id = 'A') or (p_Id = 'B')) then begin
Result := true;
Exit;
end;
Result := false;
end;
Result := ((p_Id = 'A') or (p_Id = 'B'));
That would have been enough. But this also features Exit and an asymmetrical if.
private static int alphabetToNumber(String letter) {
String s = letter.toLowerCase();
if (s.equals("a")) {
return 1;
} else if (s.equals("b")) {
return 2;
} else if (s.equals("c")) {
return 3;
} else if (s.equals("d")) {
return 4;
} else if (s.equals("e")) {
return 5;
} else if (s.equals("f")) {
return 6;
} else if (s.equals("g")) {
return 7;
} else if (s.equals("h")) {
return 8;
} else if (s.equals("i")) {
return 9;
} else if (s.equals("j")) {
return 10;
} else if (s.equals("k")) {
return 11;
} else if (s.equals("l")) {
return 12;
} else if (s.equals("m")) {
return 13;
} else if (s.equals("n")) {
return 14;
} else if (s.equals("o")) {
return 15;
} else if (s.equals("p")) {
return 16;
} else if (s.equals("q")) {
return 17;
} else if (s.equals("r")) {
return 18;
} else if (s.equals("s")) {
return 19;
} else if (s.equals("t")) {
return 20;
} else if (s.equals("u")) {
return 21;
} else if (s.equals("v")) {
return 22;
} else if (s.equals("w")) {
return 23;
} else if (s.equals("x")) {
return 24;
} else if (s.equals("y")) {
return 25;
} else if (s.equals("z")) {
return 26;
} else {
return 0;
}
}
if(
(!_.isEmpty($(switcher).val()) && value_isnt == ":empty") ||
((value_isnt) && !$(switcher).is(value_isnt) && value_isnt != ':empty') ||
(value_is && $(switcher).is(value_is) && value_is != ':empty') ||
(value_is == ':empty' && _.isEmpty($(switcher).val())) ||
(value && _switcherValue == value) ||
(valueIn && .anyMatchInArray(valueIn.split(','), .flatten([_switcherValue]))) ||
(valueOut && !.anyMatchInArray(valueOut.split(','), .flatten([_switcherValue])))
)
var validAccountData = account.email != nil
validAccountData = account.firstName != nil
validAccountData = account.lastName != nil
if validAccountData {
return account
}
return nil
Proper validation
protected void EnableEditButtons(bool Value)
{
if (Value == false)
{
buttonAdd.Disabled = true;
buttonDelete.Disabled = true;
}
else
{
buttonAdd.Disabled = false;
buttonDelete.Disabled = false;
}
}
// ...
if (IsEditable(ID))
EnableEditButtons(true);
else
EnableEditButtons(false);
I found this old code in an app I was updating for a client a number of years back. It was so good I documented it on my own blog.
contracts = Contract.objects.filter(staff=staff).filter(active=True)
if contracts.__len__() > 0:
ind = contracts.__len__() - 1
dic[‘active_contract_id’] = contracts[ind].id
else:
dic[‘active_contract_id’] = contracts[0].id
Get last object of queryset in django
UIButton * btn = [UIButton new];
[btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
//May god have mercy of me
[[btn titleLabel] setFont:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium]];
[btn setTitle:[NSString stringWithFormat:@" %@ ", btnTxt] forState:UIControlStateNormal];
[btn sizeToFit];
[btn setTitle:btnTxt forState:UIControlStateNormal];
Why keep playing with label padding or insets when you can add spaces?
/// <summary>
/// Desctop constructor
/// </summary>
...
This is best XML commentary I found so far.
i++;
i++;
i++;
i++;
Console.WriteLine(i);
He doesn't know what is " i+=4 " :||||
let foo = {} // object no. 1
let bar = {} // object no. 2
foo > bar // return false
foo < bar // return false, so maybe foo equals bar?
foo == bar // oh well, return false
// but
foo >= bar // return true, 'cause !(foo < bar) == true
return value is expected, but JS is funny
function getJSType(cppType: string) {
let typeMap = new Map<string, string>([
["Bool", "boolean"],
["Int32", "number"],
["UInt32", "number"],
["Int64", "number"],
["UInt64", "number"],
["Double", "number"],
["String", "string"],
["Object", "any"]
]);
if (typeMap.get(cppType) === undefined) {
console.error("Invalid type in getJavascriptType: " + cppType);
process.exit(1);
}
return typeMap.get(cppType);
}