Search Results

Search found 6328 results on 254 pages for 'anonymous person'.

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

  • Closure vs Anonymous function (difference?)

    - by Maxim Gershkovich
    Hi, I have been unable to find a definition that clearly explains the differences between a closure and an anonymous function. Most references I have seen clearly specify that they are distinct "things" yet I can't seem to get my head around why. Could someone please simplify it for me? What are the specific differences between these two language features? Which one is more appropriate in what scenarios?

    Read the article

  • Sorting in Hash Maps in Java

    - by Crystal
    I'm trying to get familiar with Collections. I have a String which is my key, email address, and a Person object (firstName, lastName, telephone, email). I read in the Java collections chapter on Sun's webpages that if you had a HashMap and wanted it sorted, you could use a TreeMap. How does this sort work? Is it based on the compareTo() method you have in your Person class? I overrode the compareTo() method in my Person class to sort by lastName. But it isn't working properly and was wondering if I have the right idea or not. getSortedListByLastName at the bottom of this code is where I try to convert to a TreeMap. Also, if this is the correct way to do it, or one of the correct ways to do it, how do I then sort by firstName since my compareTo() is comparing by lastName. import java.util.*; public class OrganizeThis { /** Add a person to the organizer @param p A person object */ public void add(Person p) { staff.put(p.getEmail(), p); //System.out.println("Person " + p + "added"); } /** * Remove a Person from the organizer. * * @param email The email of the person to be removed. */ public void remove(String email) { staff.remove(email); } /** * Remove all contacts from the organizer. * */ public void empty() { staff.clear(); } /** * Find the person stored in the organizer with the email address. * Note, each person will have a unique email address. * * @param email The person email address you are looking for. * */ public Person findByEmail(String email) { Person aPerson = staff.get(email); return aPerson; } /** * Find all persons stored in the organizer with the same last name. * Note, there can be multiple persons with the same last name. * * @param lastName The last name of the persons your are looking for. * */ public Person[] find(String lastName) { ArrayList<Person> names = new ArrayList<Person>(); for (Person s : staff.values()) { if (s.getLastName() == lastName) { names.add(s); } } // Convert ArrayList back to Array Person nameArray[] = new Person[names.size()]; names.toArray(nameArray); return nameArray; } /** * Return all the contact from the orgnizer in * an array sorted by last name. * * @return An array of Person objects. * */ public Person[] getSortedListByLastName() { Map<String, Person> sorted = new TreeMap<String, Person>(staff); ArrayList<Person> sortedArrayList = new ArrayList<Person>(); for (Person s: sorted.values()) { sortedArrayList.add(s); } Person sortedArray[] = new Person[sortedArrayList.size()]; sortedArrayList.toArray(sortedArray); return sortedArray; } private Map<String, Person> staff = new HashMap<String, Person>(); public static void main(String[] args) { OrganizeThis testObj = new OrganizeThis(); Person person1 = new Person("J", "W", "111-222-3333", "[email protected]"); Person person2 = new Person("K", "W", "345-678-9999", "[email protected]"); Person person3 = new Person("Phoebe", "Wang", "322-111-3333", "[email protected]"); Person person4 = new Person("Nermal", "Johnson", "322-342-5555", "[email protected]"); Person person5 = new Person("Apple", "Banana", "123-456-1111", "[email protected]"); testObj.add(person1); testObj.add(person2); testObj.add(person3); testObj.add(person4); testObj.add(person5); System.out.println(testObj.findByEmail("[email protected]")); System.out.println("------------" + '\n'); Person a[] = testObj.find("W"); for (Person p : a) System.out.println(p); System.out.println("------------" + '\n'); a = testObj.find("W"); for (Person p : a) System.out.println(p); System.out.println("SORTED" + '\n'); a = testObj.getSortedListByLastName(); for (Person b : a) { System.out.println(b); } } } Person class: public class Person implements Comparable { String firstName; String lastName; String telephone; String email; public Person() { firstName = ""; lastName = ""; telephone = ""; email = ""; } public Person(String firstName) { this.firstName = firstName; } public Person(String firstName, String lastName, String telephone, String email) { this.firstName = firstName; this.lastName = lastName; this.telephone = telephone; this.email = email; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public int compareTo(Object o) { String s1 = this.lastName + this.firstName; String s2 = ((Person) o).lastName + ((Person) o).firstName; return s1.compareTo(s2); } public boolean equals(Object otherObject) { // a quick test to see if the objects are identical if (this == otherObject) { return true; } // must return false if the explicit parameter is null if (otherObject == null) { return false; } if (!(otherObject instanceof Person)) { return false; } Person other = (Person) otherObject; return firstName.equals(other.firstName) && lastName.equals(other.lastName) && telephone.equals(other.telephone) && email.equals(other.email); } public int hashCode() { return this.email.toLowerCase().hashCode(); } public String toString() { return getClass().getName() + "[firstName = " + firstName + '\n' + "lastName = " + lastName + '\n' + "telephone = " + telephone + '\n' + "email = " + email + "]"; } }

    Read the article

  • VB.NET 2008 - Anonymous Function

    - by James Brauman
    Hi, On Form Load I populate a menu with all possible colors so they user can pick a color. However when they pick a color the forecolor of my label is not changed. Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' When the form loads, we want to populate the color menu item with all the possible colors that we could change the label to. For Each currentColor As KnownColor In [Enum].GetValues(GetType(KnownColor)) ' Declare the knowColor again - we must do this to be able to do anonymous delegates in VB.NET Dim actualCurrentColor As KnownColor = currentColor ' Get the name for this color Dim colorName As String = [Enum].GetName(GetType(KnownColor), actualCurrentColor) ' Create a new menu item for this color Dim newMenuItem As ToolStripMenuItem = New ToolStripMenuItem(colorName) ' Add a handler to this menu item so when it is clicked, we change the heading color AddHandler newMenuItem.Click, Function(s As System.Object, events As System.EventArgs) (HeadingLabel.ForeColor = Color.FromKnownColor(actualCurrentColor)) ' Add the menu item to the colors menu ColorToolStripMenuItem.DropDownItems.Add(newMenuItem) Next End Sub What am I doing wrong? Thanks

    Read the article

  • C# Anonymous method variable scope problem with IEnumerable<T>

    - by PaN1C_Showt1Me
    Hi. I'm trying to iterate through all components and for those who implements ISupportsOpen allow to open a project. The problem is when the anonymous method is called, then the component variable is always the same element (as coming from the outer scope from IEnumerable) foreach (ISupportsOpen component in something.Site.Container.Components.OfType<ISupportsOpen>()) { MyClass m = new MyClass(); m.Called += new EventHandler(delegate(object sender, EventArgs e) { if (component.CanOpenProject(..)) component.OpenProject(..); }); itemsList.Add(m); } How should it be solved, please?

    Read the article

  • detachEvent not working with named anonymous functions

    - by Polshgiant
    I ran into a problem in IE8 today (Note that I only need to support IE) that I can't seem to explain: detachEvent wouldn't work when using a named anonymous function handler. document.getElementById('iframeid').attachEvent("onreadystatechange", function onIframeReadyStateChange() { if (event.srcElement.readyState != "complete") { return; } event.srcElement.detachEvent("onreadystatechange", onIframeReadyStateChange); // code here was running every time my iframe's readyState // changed to "complete" instead of only the first time }); I eventually figured out that changing onIframeReadyStateChange to use arguments.callee (which I normally avoid) instead solved the issue: document.getElementById('iframeid').attachEvent("onreadystatechange", function () { if (event.srcElement.readyState != "complete") { return; } event.srcElement.detachEvent("onreadystatechange", arguments.callee); // code here now runs only once no matter how many times the // iframe's readyState changes to "complete" }); What gives?! Shouldn't the first snippet work fine?

    Read the article

  • Multiple return points in scala closure/anonymous function

    - by Debilski
    As far as I understand it, there is no way in Scala to have multiple return points in an anonymous function, i.e. someList.map((i) => { if (i%2 == 0) return i // the early return allows me to avoid the else clause doMoreStuffAndReturnSomething(i) }) raises an error: return outside method definition. (And if it weren’t to raise that, the code would not work as I’d like it to work.) One workaround I could thing of would be the following someList.map({ def f(i: Int):Int = { if (i%2 == 0) return i doMoreStuffAndReturnSomething(i) } f }) however, I’d like to know if there is another ‘accepted’ way of doing this. Maybe a possibility to go without a name for the inner function? (A use case would be to emulate some valued continue construct inside the loop.)

    Read the article

  • Scoping inside Javascript anonymous functions

    - by DCD
    I am trying to make a function return data from an ajax call that I can then use. The issue is the function itself is called by many objects, e.g.: function ajax_submit (obj) { var id = $(obj).attr('id'); var message = escape ($("#"+id+" .s_post").val ()); var submit_string = "action=post_message&message="+message; $.ajax({ type: "POST", url: document.location, data: submit_string, success: function(html, obj) { alert (html); } }); return false; } Which means that inside the anonymous 'success' function I have no way of knowing what the calling obj (or id) actually are. The only way I can think of doing it is to attach id to document but that just seems a bit too crude. Is there another way of doing this?

    Read the article

  • Java anonymous class efficiency implications

    - by Po
    Is there any difference in efficiency (e.g. execution time, code size, etc.) between these two ways of doing things? Below are contrived examples that create objects and do nothing, but my actual scenarios may be creating new Threads, Listeners, etc. Assume the following pieces of code happen in a loop so that it might make a difference. Using anonymous objects: void doSomething() { for (/* Assume some loop */) { final Object obj1, obj2; // some free variables IWorker anonymousWorker = new IWorker() { doWork() { // do things that refer to obj1 and obj2 } }; } } Defining a class first: void doSomething() { for (/* Assume some loop */) { Object obj1, obj2; IWorker worker = new Worker(obj1, obj2); } } static class Worker implements IWorker { private Object obj1, obj2; public CustomObject(Object obj1, Object obj2) {/* blah blah */} @Override public void doWork() {} }; Thank you :)

    Read the article

  • Where to put constant strings in C++: static class members or anonymous namespaces

    - by stone
    I need to define some constant strings that will be used only by one class. It looks like I have three options: Embed the strings directly into locations where they are used. Define them as private static constant members of the class: //A.h class A { private: static const std::string f1; static const std::string f2; static const std::string f3; }; //A.cpp const std::string f1 = "filename1"; const std::string f2 = "filename2"; const std::string f3 = "filename3"; //strings are used in this file Define them in an anonymous namespace in the cpp file: //A.cpp namespace { const std::string f1 = "filename1"; const std::string f2 = "filename2"; const std::string f3 = "filename3"; } //strings are used in this file Given these options, which one would you recommend and why? Thanks.

    Read the article

  • Silverlight datagrid don't show any data with anonymous query RIA services

    - by user289082
    Hi all! I have an anonymous linq query that I bind to a datagrid, when I debug it brings alright the data but it doesn't show in the datagrid, I suspect that the request to RIA services isn't completed before I bound it to the datagrid. I could use the LoadOperation<() Completed event. But it only works with Defined Entities so how can I do that? For reference here is the last post: http://stackoverflow.com/questions/2403903/linq-query-null-reference-exception Here is the query: var bPermisos = from b in ruc.Permisos where b.IdUsuario == SelCu.Id select new { Id=b.Id, IdUsuario=b.IdUsuario, IdPerfil=b.IdPerfil, Estatus=b.Estatus, Perfil=b.Cat_Perfil.Nombre, Sis=b.Cat_Perfil.Cat_Sistema.Nombre }; I'm a totally newbie sorry if is a very simple question. Thanks!!

    Read the article

  • matlab constant anonymous function returns only one value instead of an array

    - by Filo
    I've been searching the net for a couple of mornings and found nothing, hope you can help. I have an anonymous function like this f = @(x,y) [sin(2*pi*x).*cos(2*pi*y), cos(2*pi*x).*sin(2*pi*y)]; that needs to be evaluated on an array of points, something like x = 0:0.1:1; y = 0:0.1:1; w = f(x',y'); Now, in the above example everything works fine, the result w is a 11x2 matrix with in each row the correct value f(x(i), y(i)). The problem comes when I change my function to have constant values: f = @(x,y) [0, 1]; Now, even with array inputs like before, I only get out a 1x2 array like w = [0,1]; while of course I want to have the same structure as before, i.e. a 11x2 matrix. I have no idea why Matlab is doing this...

    Read the article

  • Anonymous method as function result

    - by iamjoosy
    What I want to do is to assign an anonymous method which I get as a function result to a variable of the same type. Delphi complains about not beeing able to do the assignement. Obviously Delphi things I want to assign the "GetListener" function instead of the result of that same function. Any help with this is very much appreciated. type TPropertyChangedListener = reference to procedure (Sender: TStimulus); TMyClass = class function GetListener:TPropertyChangedListener end; .... var MyClass: TMyClass; Listener: TPropertyChangedListener; begin MyClass:= TMyClass.create; Listener:= MyClass.GetListener; // Delphi compile error: E2010 Incompatible types: TPropertyChangedListener' and 'Procedure of object' end;

    Read the article

  • Creating anonymous functions in loop with not the same arguments

    - by onio9
    Hello! I want to make in loop set of buttons, and add to them some events, but anonymous functions is the same. I write example code: for(var i:int=0;i<5;i++) { var button:SimpleButton = new SimpleButton(...); ... button.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void { trace(i); }); } ... And I want to trace 1,2,3.. from click buttons instead of 4,4,4,4 .. Do you know how can I make this ?

    Read the article

  • Anonymous Access and Sharepoint Web Services

    - by Stacy Vicknair
    A month or so ago I was working on a feature for a project that required a level of anonymity on the Sharepoint site in order to function. At the same time I was also working on another feature that required access to the Sharepoint search.asmx web service. I found out, the hard way, that the Sharepoint Web Services do not operate in an expected way while the IIS site is under anonymous access. Even though these web services expect requests with certain permissions (in theory) they never attempt to request those credentials when the web service is contacted. As a result the services return a 401 Unauthorized response. The fix for my situation was to restrict anonymous access to the area that needed it (in this case the control in question had support for being used in an ASP.NET app that I could throw in a virtual directory). After that I removed anonymous access from IIS for the site itself and the QueryService requests were working once more. Here’s a related article with a bit more depth about a similar experience: http://chrisdomino.com/Blog/Post/401-Reasons-Why-SharePoint-Web-Services-Don-t-Work-Anonymously?Length=4 Technorati Tags: Sharepoint,QueryService,WSS,IIS,Anonymous Access

    Read the article

  • the HTTP request is unauthorized with client authentication scheme 'Anonymous'

    - by user1246429
    I use firstdata webservice API.I use C# client call firstdata webservice API with WCF. But show error message: "But show error message "System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was ''. --- System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace --- Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory) at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at com.firstdata.globalgatewaye4.api.ServiceSoap.SendAndCommit(SendAndCommitRequest request) at com.firstdata.globalgatewaye4.api.ServiceSoapClient.com.firstdata.globalgatewaye4.api.ServiceSoap.SendAndCommit (SendAndCommitRequest request) at com.firstdata.globalgatewaye4.api.ServiceSoapClient.SendAndCommit(Transaction SendAndCommitSource)" My web.config info below: <behaviors> <endpointBehaviors> <behavior name="FDGGBehavior"> <clientCredentials> <clientCertificate findValue="WS1909642825._.1" storeLocation="LocalMachine" x509FindType="FindBySubjectName" storeName="TrustedPeople" /> <serviceCertificate> <authentication certificateValidationMode="PeerTrust" /> </serviceCertificate> </clientCredentials> </behavior> </endpointBehaviors> </behaviors> <binding name="ServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="TransportWithMessageCredential"> <transport clientCredentialType="Certificate" proxyCredentialType="Ntlm" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> <endpoint address="https://api.globalgatewaye4.firstdata.com/transaction/v11" binding="basicHttpBinding" bindingConfiguration="ServiceSoap" contract="com.firstdata.globalgatewaye4.api.ServiceSoap" name="ServiceSoap" behaviorConfiguration="FDGGBehavior" /> How can resolve question?

    Read the article

  • access exception when invoking method of an anonymous class using java reflection

    - by Asaf David
    Hello I'm trying to use an event dispatcher to allow a model to notify subscribed listeners when it changes. the event dispatcher receives a handler class and a method name to call during dispatch. the presenter subscribes to the model changes and provide a Handler implementation to be called on changes. Here's the code (I'm sorry it's a bit long). EventDispacther: package utils; public class EventDispatcher<T> { List<T> listeners; private String methodName; public EventDispatcher(String methodName) { listeners = new ArrayList<T>(); this.methodName = methodName; } public void add(T listener) { listeners.add(listener); } public void dispatch() { for (T listener : listeners) { try { Method method = listener.getClass().getMethod(methodName); method.invoke(listener); } catch (Exception e) { System.out.println(e.getMessage()); } } } } Model: package model; public class Model { private EventDispatcher<ModelChangedHandler> dispatcher; public Model() { dispatcher = new EventDispatcher<ModelChangedHandler>("modelChanged"); } public void whenModelChange(ModelChangedHandler handler) { dispatcher.add(handler); } public void change() { dispatcher.dispatch(); } } ModelChangedHandler: package model; public interface ModelChangedHandler { void modelChanged(); } Presenter: package presenter; public class Presenter { private final Model model; public Presenter(Model model) { this.model = model; this.model.whenModelChange(new ModelChangedHandler() { @Override public void modelChanged() { System.out.println("model changed"); } }); } } Main: package main; public class Main { public static void main(String[] args) { Model model = new Model(); Presenter presenter = new Presenter(model); model.change(); } } Now, I except to get the "model changed" message. However, I'm getting an java.lang.IllegalAccessException: Class utils.EventDispatcher can not access a member of class presenter.Presenter$1 with modifiers "public". I understand that the class to blame is the anonymous class i created inside the presenter, however I don't know how to make it any more 'public' than it currently is. If i replace it with a named nested class it seem to work. It also works if the Presenter and the EventDispatcher are in the same package, but I can't allow that (several presenters in different packages should use the EventDispatcher) any ideas?

    Read the article

  • Given a project and working with 1 other person - never worked with someone before

    - by Celeritas
    I'm taking a class where I work with a partner to implement the link layer of the OSI model. I've worked programmed with a partner once before and it went bad. Is the goal to divide the work up and decides who does what or should one person code and the other person reviews and switch roles after a while? Any tips are much appreciated. Literally I know nothing about working with a partner to program so even if it's basic please tell me.

    Read the article

  • Frustum culling with third person camera

    - by Christian Frantz
    I have a third person camera that contains two matrices: view and projection, and two Vector3's: camPosition and camTarget. I've read up on frustum culling and it makes it seem easy enough for a first person camera, but how would I implement this for a third person camera? I need to take into effect the objects I can see behind me too. How would I implement this into my camera class so it runs at the same time as my update method? public void CameraUpdate(Matrix objectToFollow) { camPosition = objectToFollow.Translation + (objectToFollow.Backward *backward) + (objectToFollow.Up * up); camTarget = objectToFollow.Translation; view = Matrix.CreateLookAt(camPosition, camTarget, Vector3.Up); } Can I just create another method within the class which creates a bounding sphere with a value from my camera and then uses the culling based on that? And if so, which value am I using to create the bounding sphere from? After this is implemented, I'm planning on using occlusion culling for the faces of my objects adjacent to other objects. Will using just one or the other make a difference? Or will both of them be better? I'm trying to keep my framerate as high as possible

    Read the article

  • Circular dependency and object creation when attempting DDD

    - by Matthew
    I have a domain where an Organization has People. Organization Entity public class Organization { private readonly List<Person> _people = new List<Person>(); public Person CreatePerson(string name) { var person = new Person(organization, name); _people.Add(person); return person; } public IEnumerable<Person> People { get { return _people; } } } Person Entity public class Person { public Person(Organization organization, string name) { if (organization == null) { throw new ArgumentNullException("organization"); } Organization = organization; Name = name; } public Organization { get; private set; } public Name { get; private set; } } The rule for this relationship is that a Person must belong to exactly one Organization. The invariants I want to guarantee are: A person must have an organization this is enforced via the Person's constuctor An organization must know of its people this is why the Organization has a CreatePerson method A person must belong to only one organization this is why the organization's people list is not publicly mutable (ignoring the casting to List, maybe ToEnumerable can enforce that, not too concerned about it though) What I want out of this is that if a person is created, that the organization knows about its creation. However, the problem with the model currently is that you are able to create a person without ever adding it to the organizations collection. Here's a failing unit-test to describe my problem [Test] public void AnOrganizationMustKnowOfItsPeople() { var organization = new Organization(); var person = new Person(organization, "Steve McQueen"); CollectionAssert.Contains(organization.People, person); } What is the most idiomatic way to enforce the invariants and the circular relationship?

    Read the article

  • Django anonymous user in model

    - by jack
    I have a model defined as below: class Example(models.Model): user = models.ForeignKey(User, null=True) other = models.CharField(max_length=100) The problem is Django refuses to assign django.contrib.auth.models.AnonymousUser directly to Example.user as null field so everytime I have to check if request.user.is_authenticated() ans assign Example.user = None manually. Is there a default value for AnonymousUser to use in a model field?

    Read the article

  • CoffeeScript Class Properties Within Nested Anonymous Functions

    - by Aric
    I'm just taking a look at CoffeeScript for the first time so bare with me if this is a dumb question. I'm familiar with the hidden pattern methodology however I'm still wrapping my head around object prototypes. I'm trying to create a basic class for controlling a section on my site. The problem I'm running into is losing defined class variables within a different scope. For example, the code below works fine and creates the properties within the object perfectly. However when I jump into a jQuery callback I lose all knowledge of the class variables storing some of the jQuery objects for multiple uses. Is there a way to grab them from within the callback function? class Session initBinds: -> @loginForm.bind 'ajax:success', (data, status, xhr) -> console.log("processed") return @loginForm.bind 'ajax:before', (xhr, settings) -> console.log @loader // need access to Session.loader return return init: -> @loginForm = $("form#login-form") @loader = $("img#login-loader") this.initBinds() return

    Read the article

  • anonymous function variable scope [js, ajax]

    - by arthurprs
    $(".delete").click( function() { var thesender = this; $(thesender).text("Del..."); $.getJSON("ajax.php", {}, function(data) { if (data["result"]) $(thesender).remove(); // variable defined outside else alert('Error!'); } ); return false; } ); This can cause problems if user clicks on another ".delete" before the ajax callback is called?

    Read the article

  • Java Dynamic Binding

    - by Chris Okyen
    I am having trouble understanding the OOP Polymorphic principl of Dynamic Binding ( Late Binding ) in Java. I looked for question pertaining to java, and wasn't sure if a overall answer to how dynamic binding works would pertain to Java Dynamic Binding, I wrote this question. Given: class Person { private String name; Person(intitialName) { name = initialName; } // irrelevant methods is here. // Overides Objects method public void writeOutput() { println(name); } } class Student extends Person { private int studentNumber; Student(String intitialName, int initialStudentNumber) { super(intitialName); studentNumber = initialStudentNumber; } // irrellevant methods here... // overides Person, Student and Objects method public void writeOutput() { super.writeOutput(); println(studentNumber); } } class Undergaraduate extends Student { private int level; Undergraduate(String intitialName, int initialStudentNumber,int initialLevel) { super(intitialName,initialStudentNumber); level = initialLevel; } // irrelevant methods is here. // overides Person, Student and Objects method public void writeOutput() { super.writeOutput(); println(level); } } I am wondering. if I had an array called person declared to contain objects of type Person: Person[] people = new Person[2]; person[0] = new Undergraduate("Cotty, Manny",4910,1); person[1] = new Student("DeBanque, Robin", 8812); Given that person[] is declared to be of type Person, you would expect, for example, in the third line where person[0] is initialized to a new Undergraduate object,to only gain the instance variable from Person and Persons Methods since doesn't the assignment to a new Undergraduate to it's ancestor denote the Undergraduate object to access Person - it's Ancestors, methods and isntance variables... Thus ...with the following code I would expect person[0].writeOutput(); // calls Undergraduate::writeOutput() person[1].writeOutput(); // calls Student::writeOutput() person[0] to not have Undergraduate's writeOutput() overidden method, nor have person[1] to have Student's overidden method - writeOutput(). If I had Person mikeJones = new Student("Who?,MikeJones",44,4); mikeJones.writeOutput(); The Person::writeOutput() method would be called. Why is this not so? Does it have to do with something I don't understand about relating to arrays? Does the declaration Person[] people = new Person[2] not bind the method like the previous code would?

    Read the article

  • PHP anonymous functions scope question

    - by Dan
    Hi, I'm trying to sort an array of objects by a common property, however I cannot get my $property parameter to register in the inner function (I can use it in the outer one OK). The way I read the documentation, it sounded like the parameter would be available, have I misunderstood something? Here is what I have: public static function sortObjectsByProperty($objects, $property) { function compare_object($a, $b) { $a = $a->$property; $b = $b->$property; if ($a->$property == $b->$property) { return 0; } return ($a->$property > $b->$property) ? +1 : -1; } usort($objects, 'compare_object'); return $objects; } Any advice appreciated. Thanks.

    Read the article

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