Show error in the case. C++

How can I show an error to the client of my code in the case? Here is the function which will be used by someone: double firstTaskSum(int n, double x) { if(n < 0) { cout << ("n is invalid! n : " + std::to_string(n) + ". And...
more »

2017-09-09 14:09 (2) Answers

Rename a component of R lists

l1 <- list(a = 'FirstComponent', b= 'SecondComponent') To rename the first component from a to c I can do this: names(l1) <- c('c', 'b') Or this: names(l1)[1] <- c('c') But not this: names(l1[1]) <- c('c') Nor this: names(l1[[...
more »

2017-08-11 11:08 (1) Answers

How to return multiple types from a function in C?

I have a function in C which calculates the mean of an array. Within the same loop, I am creating an array of t values. My current function returns the mean value. How can I modify this to return the t array also? /* function returning the mean of a...
more »

2017-08-03 16:08 (3) Answers

rest echo vs return in GET

I am a newbie in php and rest and I'm trying to understand what is going on in my API when using echo vs return.... I've tried to get down to the simplest possible scenario to isolate an issue of my rest API not returning any value, so here is goes:...
more »

2017-07-20 19:07 (2) Answers

Java Generic Method Return Wont Compile

I have a simple class like this: public class MyClass<T> { public T myMethod() { return this.returnObj(); } Object returnObj() {..} } The above return statement in myMethod wont compile, obviously because I am returning Ob...
more »

2017-06-17 00:06 (0) Answers

PHP Class called function has a return

Try to explain my problem, I hope someone give me an advice 'cause I'm stuck on that for a while. I've 2 functions in my simple class. This class send an email. First function is called send_mail(). Meanwhile I'm using phpmailer class. public func...
more »

2017-03-29 16:03 (0) Answers

Python Function- Return Value is 'not defined'

For my encryption code, I am trying to a return a value from one function because it is used in the next. I keep getting an error, telling me that the name 'cipher_text' is not defined. Please help! Error: (line 7) decryption (cipher_text, shift)...
more »

2017-03-15 07:03 (2) Answers

Stored procedure not returning value

I'm relatively new to both, c# and Oracle. I'm having a problem with Oracle stored procedure not returning a value back to my c# code. I've spent several days looking for a solution, trying everything I could find about this topic on the web. And I s...
more »

2017-02-22 13:02 (2) Answers

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