crazykid080 14 Share 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 Link to comment Share on other sites More sharing options...
Pandemic 2675 Share 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 Link to comment Share on other sites More sharing options...
crazykid080 14 Author Share Posted November 3, 2020 Great! I'll definitely have to flesh it out a bit but I will definitely be using that method Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.