crazykid080 14 Posted November 3, 2020 I am trying to buy two Items at the same time, I currently have the code setup like if (Shop.count(itemA) != 0) { Shop.purchaseOne(itemA); return Calculations.random(100, 500); } if (Shop.count(itemB) != 0) { Shop.purchaseOne(itemB); return Calculations.random(100, 500); } Should I do it that way or do it more like if (Shop.count(itemA) != 0) { Shop.purchaseOne(itemA); } if (Shop.count(itemB) != 0) { Shop.purchaseOne(itemB); } return Calculations.random(100, 500); I see both working fine with no issues, I'm just wondering which one would be a better practice for scripting
Pandemic 2853 Posted November 3, 2020 Both will work identically, but the bottom is preferred way to do it. You normally want to extract any common logic to avoid repeating yourself
crazykid080 14 Author Posted November 3, 2020 Great! I'll definitely have to flesh it out a bit but I will definitely be using that method
Recommended Posts
Archived
This topic is now archived and is closed to further replies.