The client is offline due to RuneScape update. You may see instance errors but this is due to the update and not actual instance errors. This should be resolved soon. Join our Discord for more information.

difference between if conditions



  • what is the difference between those two way of checking a condition true/false and is one better than the other in general ?

    if (!Bank.isOpen() && Bank.open()) {
        Bank.depositAll("BlahBlah");
    }
    
    if (!Bank.isOpen()) {
        Bank.open()
        Bank.depositAll("bluhBluh";
    }
    

    So yeah, I have seen examples that use the first exam ple and others that use the second example.
    Is any of them better ?

    If I get it right, the first example that includes Bank.open() in its condition check, will EXECUTE that action and validate true if it has finished executing it ???


  • Script Writer

    They're both the same, Bank#open() would only return false if the BankLocation you input isn't correct/null, or if it has trouble loading the Scene or walking to that Bank.
    Bank#open() has a banking timeout of 2.4 seconds, which might be a bit slow for some, so you could add a sleep statement after its call.
    The only notable difference is that one can be stuffed into your condition, which may take away some readability, as people might not realize it to be an action.



  • @Dungeonqueer thank you sir this is clear and I prefer the second way of doing it then.
    cheers.


  • Script Writer

    Both are the same, it just looks nicer. You could dom something like:

    if (Bank.isOpen() || (Bank.open() && Time.sleepUntill(Bank::isOpen, 1200)) {
        Bank.withdrawAll("Something");
    }
    


  • @qverkk said in difference between if conditions:

    Both are the same, it just looks nicer. You could dom something like:

    if (Bank.isOpen() || (Bank.open() && Time.sleepUntill(Bank::isOpen, 1200)) {
        Bank.withdrawAll("Something");
    }
    

    Thanks 😄
    This indeed looks clean too...
    so now we are standing on a 1-1 fight, any third person in favor of first or second way of using if (conditions) ?


 

56
Online

16.6k
Users

1.4k
Topics

19.2k
Posts