methods

ruby object array... or hash

I have an object now: class Items attr_accessor :item_id, :name, :description, :rating def initialize(options = {}) options.each { |k,v| self.send( "#{k.to_s}=".intern, v) } end end I have it being assigned as individual objects into an array... @result = [] some loop>> @result << Items.new(opt...

tagging methods and calling them from a client object by tag

Hello, I have been trying to figure out a way to tag several methods from my base class, so that a client class can call them by tag. The example code is: public class Base { public void method1(){ ..change state of base class } public void method2(){ ..change state of base class } public void m...

Output Parameters in Java

With a third party API I observed the following. Instead of using, public static string getString(){ return "Hello World"; } it uses something like public static void getString(String output){ } and I am getting the "output" string assigned. I am curious about the reason of implementing such functionality. What are the advant...

how do set a timeout for a method

how do set a timeout for a busy method +C#. ...

Is synchronized static method legal in Java?

Thank you folks. ...

How many methods can a C# class have

Is there a limitation on number of properties, methods a C# class can have? I do a quick skim at Standard ECMA-334 and did not find any information on it. Before jumping into why a class with many methods are bad design, I want to be more clear on the intention. Of course I will not be writing a class with large number of methods manua...

Initializing a string array in a method call as a parameter in C#

If I have a method like this: public void DoSomething(int Count, string[] Lines) { //Do stuff here... } Why can't I call it like this? DoSomething(10, {"One", "Two", "Three"}); What would be the correct (but hopefully not the long way)? ...

class method inheritance question

Can anyone recommend good tutorial or a book on topics : class, methods, inheritance OOP etc .. to get general ideas .. and with some examples .. programming language is not important. tnx ...

Static Factory Methods to avoid Duplicate Objects

I was reading Joshua Bloch's "Effective Java Programming Language Guide". He explains static factory methods could be used to avoid unnecessary duplicate objects. I haven't quite understood this. Could anyone explain? ...

Python classes special methods

Could someone please give me a complete list of those special methods that you can put in classes, e.g. a couple are __len__ and __add__, but what are the rest? Thanks. ...

jQuery load() from within ajaxComplete() callback causing multiple loads

Hello, I've been staring at this one for a while and I'm completely stumped. You'll need firebug for this, take a look at the AJAX requests. They seem to be multiplying after each click of next and previous, until it's too slow to load entirely: http://www.ftsdev.com/freegreen/virtual-tour-prototype/virtual-tour.html All the JavaScrip...

Pause execution of a method without locking GUI. C#

I'm working on a card game in C# for a project on my Intro to OOP paper and have got the game working now but am adding "flair" to the GUI. Currently cards are dealt and appear on the UI instantaneously. I want to have to program pause for a moment after dealing a card before it deals the next. When a game is started the following code...

Help with PHP method_exists()

Hi I am writing a "catch all" method for my controller for ajax. It is called 'ajax' :P This is what it currently looks like public function ajax($method = null) { if ( ! $method OR ! request::is_ajax()) { return false; } if (method_exists(array($this, 'searchModel'), $method)) { echo $this->searchMode...

Can you get a method name from within a method in PHP?

Is it possible to do something like this? public function something() { $thisMethodName = method_get_name(); // I made that function up, but is there some way of doing what it describes? } Thanks ...

Can I call a static method inside another method?

fundamental question: How can I call a static method inside another method. Please help!! public static class Class1 { public static string RenderCompareStatus() { bool isFound = Class1.Found(id); } private static bool Found(string id) { } //Error message: does not contain definition for Found ...

How do you override a TableAdapter method on a Table in a DataSet?

I currently have a single DataSet declared which contains 3 tables. For sake of this example we will call them User, Question and Answer. On each of these I have a TableAdapter with the various methods required, ie. GetData(), Update(), Delete() etc. On the Answer Table I would like to override the Update Method from the TableAdapter t...

Is it possible to create instance and call method in one command (on the same line) in PHP?

Is it possible? Normally, it requires two lines: $instance = new MyClass(); $variable = $instance->method(); Is something like this possible in PHP?: $variable = new MyClass()->method(); Of course, the first code is better for readability and clean code, etc., but I was just curious if you can shrink it. Maybe it could be useful, ...

Shift + mouseover with jQuery

I'm trying to detect whether the shift key is being pressed while the cursor is moved over a particular element. The function fires, but only after I click on another element first. Is there some way to work around this? I've tried setting focus to both the document and element, and tried creating a pseudo-click function but so far nothi...

Objective C find caller of method

Is there a way to determine the line of code a certain method was called from? I ...

How to detect unused methods and #import in Objective-C

After working a long time on an iPhone app, I realized that my code it's quite dirty, containing several #import and methods that are not called or useful at all. I would like to know if there's any compiler directive or way to detect those useless lines of code. Does Xcode have any tool to detect this? ...