Search Results

Search found 34668 results on 1387 pages for 'return'.

Page 5/1387 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Do out-of-office replies get sent to the return-path header?

    - by Brian Armstrong
    I always thought that the return-path header was used for bounced messages, so I have my email newsletter software setup to unsubscribe anyone whose email address replies back to the return-path email address. But recently some users started telling me their out-of-office replies where unsubscribing them. Do out-of-office replies get sent to the return-path on some email servers? I could check all emails to that address and see if they have the "message/delivery-status" content-type in one of the parts, but I wasn't sure if this was necessary.

    Read the article

  • How can a Perl force its caller to return? [closed]

    - by JS Bangs
    Possible Duplicate: Is it possible for a Perl subroutine to force its caller to return? I want to write a subroutine which causes the caller to return under certain conditions. This is meant to be used as a shortcut for validating input to a function. What I have so far is: sub needs($$) { my ($condition, $message) = @_; if (not $condition) { print "$message\n"; # would like to return from the *parent* here } return $condition; } sub run_find { my $arg = shift @_; needs $arg, "arg required" or return; needs exists $lang{$arg}, "No such language: $arg" or return; # etc. } The advantage of returning from the caller in needs would then be to avoid having to write the repetitive or return inside run_find and similar functions.

    Read the article

  • How to name a method that both performs a task and returns a boolean as a status?

    - by Limbo Exile
    If there is a method bool DoStuff() { try { // doing stuff... return true; } catch (Exception ex) { return false; } } should it rather be called IsStuffDone()? Both names could be misinterpreted by the user: If the name is DoStuff() why does it return a boolean? If the name is IsStuffDone() it is not clear whether the method performs a task or only checks its result. Is there a convention for this case? Or an alternative approach, as this one is considered flawed? For example in languages that have output parameters, like C#, a boolean status variable could be passed to the method as one and the method's return type would be void.

    Read the article

  • Single or multiple return statements in a function [on hold]

    - by Juan Carlos Coto
    When writing a function that can have several different return values, particularly when different branches of code return different values, what is the cleanest or sanest way of returning? Please note the following are really contrived examples meant only to illustrate different styles. Example 1: Single return def my_function(): if some_condition: return_value = 1 elif another_condition: return_value = 2 else: return_value = 3 return return_value Example 2: Multiple returns def my_function(): if some_condition: return 1 elif another_condition: return 2 else: return 3 The second example seems simpler and is perhaps more readable. The first one, however, might describe the overall logic a bit better (the conditions affect the assignment of the value, not whether it's returned or not). Is the second way preferable to the first? Why?

    Read the article

  • What is the best way to return two values from a method?

    - by Edward Tanguay
    When I have to write methods which return two values, I usually go about it as in the following code which returns a List<string>. Or if I have to return e.g. a id and string, then I return a List<object> and then pick them out with index number and recast the values. This recasting and referencing by index seems inelegant so I want to develop a new habit for methods that return two values. What is the best pattern for this? using System; using System.Collections.Generic; using System.Linq; namespace MultipleReturns { class Program { static void Main(string[] args) { string extension = "txt"; { List<string> entries = GetIdCodeAndFileName("first.txt", extension); Console.WriteLine("{0}, {1}", entries[0], entries[1]); } { List<string> entries = GetIdCodeAndFileName("first", extension); Console.WriteLine("{0}, {1}", entries[0], entries[1]); } Console.ReadLine(); } /// <summary> /// gets "first.txt", "txt" and returns "first", "first.txt" /// gets "first", "txt" and returns "first", "first.txt" /// it is assumed that extensions will always match /// </summary> /// <param name="line"></param> public static List<string> GetIdCodeAndFileName(string line, string extension) { if (line.Contains(".")) { List<string> parts = line.BreakIntoParts("."); List<string> returnItems = new List<string>(); returnItems.Add(parts[0]); returnItems.Add(line); return returnItems; } else { List<string> returnItems = new List<string>(); returnItems.Add(line); returnItems.Add(line + "." + extension); return returnItems; } } } public static class StringHelpers { public static List<string> BreakIntoParts(this string line, string separator) { if (String.IsNullOrEmpty(line)) return null; else { return line.Split(new string[] { separator }, StringSplitOptions.None).Select(p => p.Trim()).ToList(); } } } }

    Read the article

  • Multiple returns: Which one sets the final return value?

    - by DR
    Given this code: String test() { try { return "1"; } finally { return "2"; } } Do the language specifications define the return value of a call to test()? In other words: Is it always the same in every JVM? In the Sun JVM the return value is 2, but I want to be sure, that this is not VM-dependant.

    Read the article

  • When does a const return type interfere with template instantiation?

    - by Rimo
    From Herb Sutter's GotW #6 Return-by-value should normally be const for non-builtin return types. ... Note: Lakos (pg. 618) argues against returning const value, and notes that it is redundant for builtins anyway (for example, returning "const int"), which he notes may interfere with template instantiation. While Sutter seems to disagree on whether to return a const value or non-const value when returning an object of a non-built type by value with Lakos, he generally agrees that returning a const value of a built-in type (e.g const int) is not a good idea. While I understand why that is useless because the return value cannot be modified as it is an rvalue, I cannot find an example of how that might interfere with template instantiation. Please give me an example of how having a const qualifier for a return type might interfere with template instantiation.

    Read the article

  • Is it advisable to have an interface as the return type?

    - by wb
    I have a set of classes with the same functions but with different logic. However, each class function can return a number of objects. It is safe to set the return type as the interface? Each class (all using the same interface) is doing this with different business logic. protected IMessage validateReturnType; <-- This is in an abstract class public bool IsValid() <-- This is in an abstract class { return (validateReturnType.GetType() == typeof(Success)); } public IMessage Validate() { if (name.Length < 5) { validateReturnType = new Error("Name must be 5 characters or greater."); } else { validateReturnType = new Success("Name is valid."); } return validateReturnType; } Are there any pitfalls with unit testing the return type of an function? Also, is it considered bad design to have functions needing to be run in order for them to succeed? In this example, Validate() would have to be run before IsValid() or else IsValid() would always return false. Thank you.

    Read the article

  • When should one use "out" parameters?

    - by qegal
    In Objective-C, there are several methods like initWithContentsOfFile:encoding:error: where one passes in a reference to an NSError object for the error: parameter. In this example, the value of the NSError object passed in can change based on what goes on at runtime when the method is being called and whether the body of the method was executed in a certain way successfully. In a way I think of this NSError object as sort of like a second return value from the method, and only differs from an object anObject in the statement return anObject; in that when this statement is called, execution leaves the method. So my question is, not only in the context of error handling in Objective-C, but in general, when should one use an "out" parameter in place of returning said value in a return statement?

    Read the article

  • Does -localizedDescription of NSError return the actual localized string, or does it return a key fo

    - by mystify
    Must I do something like this? NSString *errorDescription = [error localizedDescription]; NSString *errorInfoStr = NSLocalizedString(errorDescription, nil); Or do I use NSLocalizedString already when populating the userInfo dictionary with the NSLocalizedDescriptionKey key and value? So the value for that is not actually a key for NSLocalizedString, but it is the actual localized string ready to show up on screen?

    Read the article

  • .Net in HTML tp return true if reader object not null, otherwise return false

    - by Phill Healey
    I'm using a DataList to show some data from the database and populating the fields on the html side. I now have a requirement to change the visibility of a panel based on whether or not a db field has data or not. I need to be able to show the panel if the relevant data field has content, and hide it if it doesn't. Eg: <asp:Panel ID="pnlNew" runat="server" Style="margin:0; padding:0; width:42px; height:18px; bottom:5px; right:10px; float:right; position:relative; background:url(../_imgVideoBadge.png) no-repeat;" Visible='<%# Eval("cheese") != null %>' ToolTip="available"></asp:Panel> Obviously this doesn't work in terms of the visible property. But hopefully it gives an idea of what I'm trying to achieve. Any help would be greatly appreciated. I've seen examples previously of doing something along the lines of: a ?? b:c How could this be applied to the above requirement?? Thanks in advance.

    Read the article

  • returning a heap block by reference in c++

    - by basicR
    I was trying to brush up my c++ skills. I got 2 functions: concat_HeapVal() returns the output heap variable by value concat_HeapRef() returns the output heap variable by reference When main() runs it will be on stack,s1 and s2 will be on stack, I pass the value by ref only and in each of the below functions, I create a variable on heap and concat them. When concat_HeapVal() is called it returns me the correct output. When concat_HeapRef() is called it returns me some memory address (wrong output). Why? I use new operator in both the functions. Hence it allocates on heap. So when I return by reference, heap will still be VALID even when my main() stack memory goes out of scope. So it's left to OS to cleanup the memory. Right? string& concat_HeapRef(const string& s1, const string& s2) { string *temp = new string(); temp->append(s1); temp->append(s2); return *temp; } string* concat_HeapVal(const string& s1, const string& s2) { string *temp = new string(); temp->append(s1); temp->append(s2); return temp; } int main() { string s1,s2; string heapOPRef; string *heapOPVal; cout<<"String Conact Experimentations\n"; cout<<"Enter s-1 : "; cin>>s1; cout<<"Enter s-2 : "; cin>>s2; heapOPRef = concat_HeapRef(s1,s2); heapOPVal = concat_HeapVal(s1,s2); cout<<heapOPRef<<" "<<heapOPVal<<" "<<endl; return -9; }

    Read the article

  • How we can execute a javascript function and get a return value in our android application?

    - by JAC
    How we can execute a javascript function and get a return value in our android appplication ? We have a javascript file that stored in our sqlite db, We want to execute that script on a button press event, we need to pass parameters to the script and get return values, how we can implement this? sample script file stored in Db is, <html><head><title>ADV</title><script type="text/javascript"> function checkName(pname) if( pname == 'android') { return false; }else { return true; } } </script></head><body></Body></html>

    Read the article

  • C++11 Tidbits: Decltype (Part 2, trailing return type)

    - by Paolo Carlini
    Following on from last tidbit showing how the decltype operator essentially queries the type of an expression, the second part of this overview discusses how decltype can be syntactically combined with auto (itself the subject of the March 2010 tidbit). This combination can be used to specify trailing return types, also known informally as "late specified return types". Leaving aside the technical jargon, a simple example from section 8.3.5 of the C++11 standard usefully introduces this month's topic. Let's consider a template function like: template <class T, class U> ??? foo(T t, U u) { return t + u; } The question is: what should replace the question marks? The problem is that we are dealing with a template, thus we don't know at the outset the types of T and U. Even if they were restricted to be arithmetic builtin types, non-trivial rules in C++ relate the type of the sum to the types of T and U. In the past - in the GNU C++ runtime library too - programmers used to address these situations by way of rather ugly tricks involving __typeof__ which now, with decltype, could be rewritten as: template <class T, class U> decltype((*(T*)0) + (*(U*)0)) foo(T t, U u) { return t + u; } Of course the latter is guaranteed to work only for builtin arithmetic types, eg, '0' must make sense. In short: it's a hack. On the other hand, in C++11 you can use auto: template <class T, class U> auto foo(T t, U u) -> decltype(t + u) { return t + u; } This is much better. It's generic and a construct fully supported by the language. Finally, let's see a real-life example directly taken from the C++11 runtime library as implemented in GCC: template<typename _IteratorL, typename _IteratorR> inline auto operator-(const reverse_iterator<_IteratorL>& __x, const reverse_iterator<_IteratorR>& __y) -> decltype(__y.base() - __x.base()) { return __y.base() - __x.base(); } By now it should appear be completely straightforward. The availability of trailing return types in C++11 allowed fixing a real bug in the C++98 implementation of this operator (and many similar ones). In GCC, C++98 mode, this operator is: template<typename _IteratorL, typename _IteratorR> inline typename reverse_iterator<_IteratorL>::difference_type operator-(const reverse_iterator<_IteratorL>& __x, const reverse_iterator<_IteratorR>& __y) { return __y.base() - __x.base(); } This was guaranteed to work well with heterogeneous reverse_iterator types only if difference_type was the same for both types.

    Read the article

  • Recursion with an Array; can't get the right value to return

    - by Matt
    Recursive Solution: Not working! Explanation: An integer, time, is passed into the function. It's then used to provide an end to the FOR statement (counter<time). The IF section (time == 0) provides a base case where the recursion should terminate, returning 0. The ELSE section is where the recursive call occurs: total is a private variable defined in the header file, elsewhere. It's initialized to 0 in a constructor, elsewhere. The function calls itself, recursively, adding productsAndSales[time-1][0] to total, again, and again, until the base call. Then the total is returned, and printed out later. Well, that's what I hoped for anyway. What I imagined would happen is that I would add up all the values in this one column of the array and the value would get returned, and printed out. Instead if returns 0. If I set the IF section to "return 1", I noticed that it returns powers of 2, for whatever value time is. EG: Time = 3, it returns 2*2 + 1. If time = 5, it returns 2*2*2*2 + 1. I don't understand why it's not returning the value I'm expecting. int CompanySales::calcTotals( int time ) { cout << setw( 4 ); if ( time == 0 ) { return 0; } else { return total += calcTotals( productsAndSales[ time-1 ][ 0 ]); } } Iterative Solution: Working! Explanation: An integer, time, is passed into the function. It's then used to provide an end to the FOR statement (counter<time). The FOR statement cycles through an array, adding all of the values in one column together. The value is then returned (and elsewhere in the program, printed out). Works perfectly. int CompanySales::calcTotals( int time ) { int total = 0; cout << setw( 4 ); for ( int counter = 0; counter < time; counter++ ) { total += productsAndSales[counter][0]; } return total0; }

    Read the article

  • What is the carriage return character in an AS/400 db?

    - by donde
    I have a client running an AS/400. I have to ftp a flat file over to them. They tell me their return charaters are RN. I don't recognize this, could not find anything on it, and their tech guy is Nick Burns so he refuses to give me any dirtection. Is there a standard return code for AS/400? I should have mentioned that I have a c# .NET 2.0 console application.

    Read the article

  • how to return 2 values from a java function?

    - by javaLearner.java
    Here is my code: // Function code public static int something(){ int number1 = 1; int number2 = 2; return number1, number2; } // Main class code public static void main(String[] args) { something(); System.out.println(number1 + number2); } Error: Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - missing return statement at assignment.Main.something(Main.java:86) at assignment.Main.main(Main.java:53) Java Result: 1

    Read the article

  • How do you return draggable content to their original positions in iPhone dev?

    - by Matt Thomas
    I am wanting to create a button in my iPhone app that when touched will return other draggable elements to their original position. I have looked at the Apple "MoveMe' example, but that returns the button to the center of the screen. I want to be able to position draggable objects around the screen, drag the objects within the app, and then return them to their original starting positions by pressing a designated button. Any help appreciated!

    Read the article

  • Python C API return more than one value / object

    - by Grisu
    I got the following problem. I have written a C-Extension to Python to interface a self written software library. Unfortunately I need to return two values from the C function where the last one is optional. In Python the equivalent is def func(x,y): return x+y, x-y test = func(13,4) #only the first value is used In my C extension I use return Py_BuildValue("ii",x+y,x-y); which results in a tuple. If I now try to access the return value from Python via test2 = cfunc(13,4) print(test2) I got a tuple instead of only the first return value. How is possible to build the same behavior as in Python from C Extension?

    Read the article

  • Should a setter return immediately if assigned the same value?

    - by Andrei Rinea
    In classes that implement INotifyPropertyChanged I often see this pattern : public string FirstName { get { return _customer.FirstName; } set { if (value == _customer.FirstName) return; _customer.FirstName = value; base.OnPropertyChanged("FirstName"); } } Precisely the lines if (value == _customer.FirstName) return; are bothering me. I've often did this but I am not that sure it's needed nor good. After all if a caller assigns the very same value I don't want to reassign the field and, especially, notify my subscribers that the property has changed when, semantically it didn't. Except saving some CPU/RAM/etc by freeing the UI from updating something that will probably look the same on the screen/whatever_medium what do we obtain? Could some people force a refresh by reassigning the same value on a property (NOT THAT THIS WOULD BE A GOOD PRACTICE HOWEVER)? 1. Should we do it or shouldn't we? 2. Why?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >