Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
in C# it would have been:
if(!int.TryParse(strVal, out int intVal) && intVal != 2 && intVal != 3){
return;
}
in Swift:
guard let intVal = Int(strVal), intVal == 2 || intVal == 3 else{
return
}
for me being able to do that it will make a mess in my code, maybe its just me ... -
@davide ooh that looks much better than try catch code, but doesn't it produce exceptions? Not a PHP dev just wondering
-
davide24247y@gitpush These functions doesn't produce an exception. They return only a boolean value
-
never mind me, just saw the is_number function so no chance for an exception when parsing it to int
-
xsacha4317yint val = 0;
std::from_chars(idOperation, std::next(idOperation, length), val);
if (val != 2 && val != 3) return; -
Root797797yRuby:
return unless idOperation.is_a? Number
return unless [2,3].includes? idOperation.to_i
Related Rants
Ok guys, you surely want to kill me, but I so love PHP in this case
undefined
insane
makesense
php