Search Results

Search found 2457 results on 99 pages for 'implicit cast'.

Page 10/99 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • http(/* argument here */) How is this Object (Http) being used without an explicit or implicit meth

    - by Randin
    In the example for coding with Json using Databinder Dispatch Nathan uses an Object (Http) without a method, shown here: import dispatch._ import Http._ Http("http://www.fox.com/dollhouse/" >>> System.out ) How is he doing this? Thank you for all of the answers unfortunatly I was not specific enough... It looks like it is simply passing an argument to a constructor of class or companion object Http. In another example, I've seen another form: http = new Http http(/* argument here */) Is this valid Scala? I guess it must be, because the author is a Scala expert. But it makes no sense to me. Actions are usually performed by invoking methods on objects, whether explicitly as object.doSomething() or implicitly as object = something (using the apply() method underneath the syntactic sugar). All I can think of is that a constructor is being used to do something in addition to constructing an object. In other words, it is having side effects, such as in this case going off and doing something on the web.

    Read the article

  • Source of UIView Implicit Animation delay?

    - by iPhoneToucher
    I have a block of UIView animation code that looks like this: [UIView beginAnimations:@"pushView" context:nil]; [UIView setAnimationDelay:0]; [UIView setAnimationDuration:.5]; [UIView setAnimationDelegate:self]; [UIView setAnimationWillStartSelector:@selector(animationWillStart)]; view.frame = CGRectMake(0, 0, 320, 416); [UIView commitAnimations]; The code basically mimics the animation of a ModalView presentation and is tied to a button on my interface. When the button is pressed, I get a long (.5 sec) delay (on iPod Touch...twice as fast on iPhone 3GS) before the animationWillStart: actually gets called. My app has lots going on besides this, but I've timed various points of my code and the delay definitely occurs at this block. In other words, a timestamp immediately before this code block and a timestamp when animationWillStart: gets called shows a .5 sec difference. I'm not too experienced with Core Animation and I'm just trying to figure out what the cause of the delay is...Memory use is stable when the animation starts and CoreAnimation FPS seems to be fine in Instruments. The view that gets animated does have upwards of 20 total subviews, but if that were the issue wouldn't it cause choppiness after the animation starts, rather than before? Any ideas?

    Read the article

  • Unbelievable: Cannot cast from class X to its super class

    - by Phuong Nguyen de ManCity fan
    I'm encountering a very weird problem with Spring (3.0.1.RELEASE), TestNG (5.11) and Maven Surefire (2.5). I have a test class that extends a Spring helper class for testNG so that test context can be loaded from an xml file (that contains some bean definitions). My project was imported into eclipse using m2eclipse (using Import Maven Project) The class run fine in Eclipse TestNG runner. However, it throws this exception with Maven Surefire Caused by: java.lang.ClassCastException: com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl cannot be cast to javax.xml.parsers.DocumentBuilderFactory at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:123) at org.springframework.beans.factory.xml.DefaultDocumentLoader.createDocumentBuilderFactory(DefaultDocumentLoader.java:89) at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:70) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388) I have eliminated all involved dependencies in my pom so that the two classes com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl and javax.xml.parsers.DocumentBuilderFactory are coming from JRE only (the rt.jar). So, it looks so unbelievable to me. I wonder if there is any mechanism in loading class that can explain for this behavior? Thanks.

    Read the article

  • Service Broker message_body error when casting binary data to xml in C#

    - by TimBuckTwo
    I am using Message Broker with Sql server 2008, and designing an External Activator service to consume messages from my target queue. My Problem: Cant cast the returned message body from the SqlDataReader object: "WAITFOR (RECEIVE TOP(1) conversation_handle, message_type_name, message_body FROM [{1}]), TIMEOUT {2}" operation, I cant cast the binary data to XML in C# SqlBinary MessageBody = reader.GetSqlBinary(2); MemoryStream memstream = new MemoryStream(); XmlDocument xmlDoc = new XmlDocument(); memstream.Write(MessageBody.Value, 0, MessageBody.Length); memstream.Position= 0; //below line Fails With Error:{"Data at the root level is invalid. Line 1, position 1."} xmlDoc.LoadXml(Encoding.ASCII.GetString(memstream.ToArray())); memstream.Close(); To prevent poison message I do not use CAST(message_body as XML), Any suggestions would be greatly appreciated.

    Read the article

  • Implicit and Explicit implementation of interface.

    - by Amby
    While working on a upgrade i happened to come across a code like this. interface ICustomization { IMMColumnsDefinition GetColumnsDefinition(); } class Customization : ICustomization { private readonly ColumnDefinition _columnDefinition; //More code here. public ColumnsDefinition GetColumnsDefinition() { return _columnDefinition; } ColumnsDefinition ICustomization.GetColumnsDefinition() //redundant { return GetColumnsDefinition(); } } My question is: Is there any need/use of 'explicit' implementation of interface in this piece of code? Will it create any problem if i remove the method (explicit implementation of interface) that i have marked "redundant" above? PS: I understand that explicit implementation of interface is very important, and it can be used when we need to give access to a method at interface level only, and to use two interface with same signature of method.

    Read the article

  • MyClass cannot be cast to java.lang.Comparable: java.lang.ClassCastException

    - by user2234225
    I am doing a java project and I got this problem and don't know how to fix it. The classes in my project (simplified): public class Item { private String itemID; private Integer price; public Integer getPrice() { return this.price; } } public class Store { private String storeID; private String address; } public class Stock { private Item item; private Store store; private Integer itemCount; public Integer getInventoryValue() { return this.item.getPrice() * this.itemCount; } } Then I try to sort an ArrayList of Stock so I create another class called CompareByValue public class CompareByValue implements Comparator<Stock> { @Override public int compare(Stock stock1, Stock stock2) { return (stock1.getInventoryValue() - stock2.getInventoryValue()); } } When I try to run the program, it gives the error: Exception in thread "main" java.lang.ClassCastException: Stock cannot be cast to java.lang.Comparable Anyone know what's wrong?

    Read the article

  • explicit copy constructor or implicit parameter by value

    - by R Samuel Klatchko
    I recently read (and unfortunately forgot where), that the best way to write operator= is like this: foo &operator=(foo other) { swap(*this, other); return *this; } instead of this: foo &operator=(const foo &other) { foo copy(other); swap(*this, copy); return *this; } The idea is that if operator= is called with an rvalue, the first version can optimize away construction of a copy. So when called with a rvalue, the first version is faster and when called with an lvalue the two are equivalent. I'm curious as to what other people think about this? Would people avoid the first version because of lack of explicitness? Am I correct that the first version can be better and can never be worse?

    Read the article

  • FreeLibrary vs implicit unloading DLL

    - by Adil
    I have implemented a DLL including DllMain() entry function:- BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { case DLL_PROCESS_ATTACH: ... case DLL_THREAD_ATTACH: ... case DLL_THREAD_DETACH: ... case DLL_PROCESS_DETACH: ... } Unfortunately i made a mistake in DLL_PROCESS_DETACH case and accessing illegal memorey (access violation). I made a sample program which loads the library using LoadLibrary() function, uses the library function and finally call FreeLibrary() and return. When i executed this program, i didnt get any error message. But if i remove FreeLibrary(), in that case the DLL_PROCESS_DETACH case is executed implicitly and this time it gives error dialog box mentioning that there is access violation. Why calling FreeLibrary() suppress this error? OR internally it handles this exception? What is suggested way.

    Read the article

  • Avoid implicit conversion from date to timestamp for selects with Oracle using Hibernate

    - by sapporo
    I'm using Hibernate 3.2.7.GA criteria queries to select rows from an Oracle Enterprise Edition 10.2.0.4.0 database, filtering by a timestamp field. The field in question is of type java.util.Date in Java, and DATE in Oracle. It turns out that the field gets mapped to java.sql.Timestamp, and Oracle converts all rows to TIMESTAMP before comparing to the passed in value, bypassing the index and thereby ruining performance. One solution would be to use Hibernate's sqlRestriction() along with Oracle's TO_DATE function. That would fix performance, but requires rewriting the application code (lots of queries). So is there a more elegant solution? Since Hibernate already does type mapping, could it be configured to do the right thing? Update: The problem occurs in a variety of configurations, but here's one specific example: Oracle Enterprise Edition 10.2.0.4.0 Oracle JDBC Driver 11.1.0.7.0 Hibernate 3.2.7.GA Hibernate's Oracle10gDialect Java 1.6.0_16

    Read the article

  • Cast an instance of a class to a @protocol in Objective-C

    - by Ford
    I have an object (a UIViewController) which may or may not conform to a protocol I've defined. I know I can determine if the object conforms to the protocol, then safely call the method: if([self.myViewController conformsToProtocol:@protocol(MyProtocol)]) { [self.myViewController protocolMethod]; // <-- warning here } However, XCode shows a warning: warning 'UIViewController' may not respond to '-protocolMethod' What's the right way to prevent this warning? I can't seem to cast self.myViewController as a MyProtocol class. Update Andy's answer below is close, but includes an unneccesary '*'. The following works: [(id<MyProtocol>)self.myViewController protocolMethod];

    Read the article

  • C++ Templates: implicit conversion, no matching function for call to ctor

    - by noname
    template<class T> class test { public: test() { } test(T& e) { } }; int main() { test<double> d(4.3); return 0; } Compiled using g++ 4.4.1 with the following errors: g++ test.cpp -Wall -o test.exe test.cpp: In function 'int main()': test.cpp:18: error: no matching function for call to 'test<double>::test(double) ' test.cpp:9: note: candidates are: test<T>::test(T&) [with T = double] test.cpp:5: note: test<T>::test() [with T = double] test.cpp:3: note: test<double>::test(const test<double>&) make: *** [test.exe] Error 1 However, this works: double a=1.1; test<double> d(a); Why is this happing? Is it possible that g++ cannot implicitly convert literal expression 1.1 to double? Thanks.

    Read the article

  • Postgresql: Implicit lock acquisition from foreign-key constraint evaluation

    - by fennec
    So, I'm being confused about foreign key constraint handling in Postgresql. (version 8.4.4, for what it's worth). We've got a couple of tables, mildly anonymized below: device: (id, blah, blah, blah, blah, blah x 50)… primary key on id whooooole bunch of other junk device_foo: (id, device_id, left, right) Foreign key (device_id) references device(id) on delete cascade; primary key on id btree index on 'left' and 'right' So I set out with two database windows to run some queries. db1> begin; lock table device in exclusive mode; db2> begin; update device_foo set left = left + 1; The db2 connection blocks. It seems odd to me that an update of the 'left' column on device_stuff should be affected by activity on the device table. But it is. In fact, if I go back to db1: db1> select * from device_stuff for update; *** deadlock occurs *** The pgsql log has the following: blah blah blah deadlock blah. CONTEXT: SQL statement "SELECT 1 FROM ONLY "public"."device" x WHERE "id" OPERATOR(pg_catalog.=) $1 FOR SHARE OF X: update device_foo set left = left + 1; I suppose I've got two issues: the first is that I don't understand the precise mechanism by which this sort of locking occurs. I have got a couple of useful queries to query pg_locks to see what sort of locks a statement invokes, but I haven't been able to observe this particular sort of locking when I run the update device_foo command in isolation. (Perhaps I'm doing something wrong, though.) I also can't find any documentation on the lock acquisition behavior of foreign-key constraint checks. All I have is a log message. Am I to infer from this that any change to a row will acquire an update lock on all the tables which it's foreign-keyed against? The second issue is that I'd like to find some way to make it not happen like that. I'm ending up with occasional deadlocks in the actual application. I'd like to be able to run big update statements that impact all rows on device_foo without acquiring a big lock on the device table. (There's a lot of access going on in the device table, and it's kind of an expensive lock to get.)

    Read the article

  • Cast element in Java For Each statement

    - by Carl Summers
    Is it possible (or even advisable) to cast the element retrieved from a for each statement in the statement itself? I do know that each element in list will be of type . I.E.: List<BaseType> list = DAO.getList(); for(<SubType> element : list){ // Cannot convert from element type <BaseType> to <SubType> ... } rather than: List <BaseType> list = DAO.getList(); for(<BaseType> el : list){ <SubType> element = (<SubType>)el; ... }

    Read the article

  • No-overflow cast on x64

    - by Cheeso
    I have an existing C codebase that works on x86. I'm now compiling it for x64. What I'd like to do is cast a size_t to a DWORD, and throw an exception if there's a loss of data. Q: Is there an idiom for this? Here's why I'm doing this: A bunch of Windows APIs accept DWORDs as arguments, and the code currently assumes sizeof(DWORD)==sizeof(size_t). That assumption holds for x86, but not for x64. So when compiling for x64, passing size_t in place of a DWORD argument, generates a compile-time warning. In virtually all of these cases the actual size is not going to exceed 2^32. But I want to code it defensively and explicitly. This is my first x64 project, so... be gentle.

    Read the article

  • Template class implicit copy constructor issues

    - by Nate
    Stepping through my program in gdb, line 108 returns right back to the calling function, and doesn't call the copy constructor in class A, like (I thought) it should: template <class S> class A{ //etc... A( const A & old ){ //do stuff... } //etc... }; template <class T> class B{ //etc... A<T> ReturnsAnA(){ A<T> result; // do some stuff with result return result; //line 108 } //etc... }; Any hints? I've banged my head against the wall about this for 4 hours now, and can't seem to come up with what's happening here.

    Read the article

  • The implicit function __strcpy_chk() call

    - by Summer_More_More_Tea
    Hi everyone: I'm now performing a stack buffer overflow attack test on my own PC( Ubuntu 9.10, gcc-4.4.1 ) based on the article http://www.tenouk.com/Bufferoverflowc/Bufferoverflow4.html. Yet I haven't achieved the goal. Each time a segfault is thrown accompanied with some error informaiton. I compile the source code, and wanna get further information using objdump. Function __strcpy_chk is invoked in the assembly code dumped out, and it's said that "The __strcpy_chk() function is not in the source standard; it is only in the binary standard." Does this the mechanism a compiler employed to protect runtime stack? To finish my test, how can I bypass the protection? Regards.

    Read the article

  • JSP Problem ussing implicit object (session) in a function

    - by user234666
    Can the object of type HttpSession called session be accessed from a function? In a simple jsp page I have a function(see below) defined in the header of the page, and set to an onclick handle of for a button. When I press this button, I'll never see the second alert message. If I do something in the body of the page (like Session ID: <%= session.getId() % ) I have no trouble accessing it. What newbie mistake am I making? function doTest() { alert('Preforming test 122333232'); String sessionId = session.getId(); alert('After access'); if(sessionId == null) { alert('session id is null?'); } Thanks

    Read the article

  • C++ Implicit Conversion Operators

    - by Imbue
    I'm trying to find a nice inheritance solution in C++. I have a Rectangle class and a Square class. The Square class can't publicly inherit from Rectangle, because it cannot completely fulfill the rectangle's requirements. For example, a Rectangle can have it's width and height each set separately, and this of course is impossible with a Square. So, my dilemma. Square obviously will share a lot of code with Rectangle; they are quite similar. For examlpe, if I have a function like: bool IsPointInRectangle(const Rectangle& rect); it should work for a square too. In fact, I have a ton of such functions. So in making my Square class, I figured I would use private inheritance with a publicly accessible Rectangle conversion operator. So my square class looks like: class Square : private Rectangle { public: operator const Rectangle&() const; }; However, when I try to pass a Square to the IsPointInRectangle function, my compiler just complains that "Rectangle is an inaccessible base" in that context. I expect it to notice the Rectangle operator and use that instead. Is what I'm trying to do even possible? If this can't work I'm probably going to refactor part of Rectangle into MutableRectangle class. Thanks.

    Read the article

  • C# XOR on two byte variables will not compile without a cast

    - by Ash
    Why does the following raise a compile time error: 'Cannot implicitly convert type 'int' to 'byte': byte a = 25; byte b = 60; byte c = a ^ b; This would make sense if I were using an arithmentic operator because the result of a + b could be larger than can be stored in a single byte. However applying this to the XOR operator is pointless. XOR here it a bitwise operation that can never overflow a byte. using a cast around both operands works: byte c = (byte)(a ^ b);

    Read the article

  • Unable to type cast <AnonymousType#1> to <WindowsFormsApplication1.Attributes> [ C#3.0 ]

    - by Newbie
    I have List<Attributes> la = new List<Attributes>(); la = (from t in result let t1 = t.AttributeCollection from t2 in t1 where t2.AttributeCode.Equals(attributeType) let t3 = t2.TimeSeriesData from k in t3.ToList() where k.Key.Equals(startDate) && k.Key.Equals(endDate) select new { AttributeCode = attributeType, TimeSeriesData = fn(k.Key, k.Value.ToString()) }).ToList<Attributes>(); I am getting the error: 'System.Collections.Generic.IEnumerable<AnonymousType#1>' does not contain a definition for 'ToList' and the best extension method overload 'System.Linq.Enumerable.ToList<TSource>(System.Collections.Generic.IEnumerable<TSource>)' has some invalid arguments I understood tye error meaning but how to type cast it. I have used var and then iterating over it got the result. But without that any other way by which I can do it? Using C# 3.0 Thanks

    Read the article

  • Explicit or implicit execution control statement use

    - by Andrei Rinea
    I sometimes use if (this._currentToolForeColor.HasValue) return this._currentToolForeColor.Value; else throw new InvalidOperationException(); other times I use if (this._currentToolForeColor.HasValue) return this._currentToolForeColor.Value; throw new InvalidOperationException(); The two are equivalent, I know, but I am not sure which is the best and why. This goes even further as you can use other execution-control statements such as brake or continue : while(something) { if(condition) { DoThis(); continue; } else break; } versus while(something) { if(condition) { DoThis(); continue; } break; } EDIT 1 : Yes the loop example(s) suck because they are synthetic (i.e.: made up for this question) unlike the first which is practical.

    Read the article

  • Ruby: rules for implicit hashes

    - by flyer
    Why second output shows me only one element of Array? Is it still Array or Hash already? def printArray(arr) arr.each { | j | k, v = j.first printf("%s %s %s \n", k, v, j) } end print "Array 1\n" printArray( [ {kk: { 'k1' => 'v1' }}, {kk: { 'k2' => 'v2' }}, {kk: { 'k3' => 'v3' }}, ]) print "Array 2\n" printArray( [ kk: { 'k1' => 'v1' }, kk: { 'k2' => 'v2' }, kk: { 'k3' => 'v3' }, ]) exit # Output: # # Array 1 # kk {"k1"=>"v1"} {:kk=>{"k1"=>"v1"}} # kk {"k2"=>"v2"} {:kk=>{"k2"=>"v2"}} # kk {"k3"=>"v3"} {:kk=>{"k3"=>"v3"}} # Array 2 # kk {"k3"=>"v3"} {:kk=>{"k3"=>"v3"}}

    Read the article

  • assignment makes pointer from integer without a cast

    - by mrblippy
    hi, i am trying to make a linked list and create some methods. but i am getting the error assignment makes pointer from integer without a cast. #include <stdio.h> #include <stdlib.h> #include "students.h" node_ptr create(void) { node_ptr students = (node_ptr) malloc(sizeof(struct node)); students->ID = 0; students->name = NULL; students->next = NULL; return students; } void insert_in_order(int n, node_ptr list) { node_ptr before = list; node_ptr new_node = (node_ptr) malloc(sizeof(struct node)); new_node->ID = n;//error is here i think while(before->next && (before->next->ID < n)) { before = before->next; } new_node->next = before->next; before->next = new_node; }

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >