Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby not Saving/Storing Values
    text
    copied!<p>My problem is that <code>chips</code> is not saving as a global variable for the argument it is passed. I am passing <code>$h1c</code> <em>(which is the number of total chips player's first hand has)</em>. So if he wins or loses, <code>chips</code> should then be set equal to <code>chips</code> <code>+</code> or <code>-</code> <code>betamount</code>.</p> <p>The problem is that it's not being saved as the global variable. If I were to write <code>$h1c = 150_000</code>, then it would equal that. If later on I write <code>$h1c = 150_000 + 50_000</code>, then 200_000 would be the new value of $h1c. </p> <p>For some reason this isn't working when I declare <code>chips = chips + betamount</code> , which is the same as saying <code>$h1c = $h1c + $h1bet</code>. </p> <pre><code>def review(hand, chips, betamount) abc = valueofcards(hand) #player's hand value klm = valueofcards($handD) #dealer's hand value if abc == klm and abc &lt; 19 puts "You tied" chips = chips elsif abc &gt; 18 puts "You lost" chips = chips - betamount elsif abc &lt; 19 and klm &gt; 18 puts "You won" chips = chips + betamount elsif abc &lt; 19 and abc &gt; klm puts "You won" chips = chips + betamount elsif abc &lt; 19 and klm &lt; 19 and klm &gt; abc puts "You lost" chips = chips - betamount end end </code></pre> <p>This is the where I pass the arguments to review:</p> <pre><code>def pre_review(num) puts "Recap of that round" puts "First Hand:" review($hand1, $h1c, $h1bet) muckcards(num) end </code></pre> <p>If need be, here is the link to the full code/game to test the problem out <a href="http://labs.codecademy.com/Bmvl#:workspace" rel="nofollow">http://labs.codecademy.com/Bmvl#:workspace</a> <em>Note: That I'm currently just trying to get this portion to work for $hand1, so you would select 1 for number of hands to play to reproduce this problem.</em></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload