How do I cache the value?

I have an assignment in school. I want to write javascript code that calculets the fibonacci sequence. I think I have a solution for that (see code below) but now I want to save the previous value so when the function is called again, it donĀ“t have ...
more »

2017-01-10 00:01 (0) Answers

Return value of a function in C

I tried writing some code to check if the paranthesis in an expression are balances using the below function. Can someone help me understand why the below function is returning 1 in case of a balanced expression when it's not specified anywhere to re...
more »

2016-12-18 10:12 (3) Answers

auto vs auto&& for a function return value

Could you tell me please whether I am right that use of auto&& for a function return value is always a better choice than use of auto. For instance, in auto val = someObj.getVal(); the val will be a copy if getVal() returns a reference. Ho...
more »

2016-10-31 08:10 (1) Answers

Return value of initialize method

Can someone more versed in ruby than I please answer why the following returns nothing? class ThreeAndFive def initialize(low_number, high_number) @total = 0 (low_number..high_number).each do |number| if (number % 3 == 0 && n...
more »

2016-10-07 22:10 (3) Answers