Search Results

Search found 2970 results on 119 pages for 'implicit typing'.

Page 7/119 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Typing Japanese on Windows Vista with Dvorak

    - by Ken
    I'm using Windows Vista, and I type English with the Dvorak keyboard layout, and I want to be able to type Japanese text that way, too. I've figured out how to set it up to let me type Japanese here, but it uses QWERTY. What I've got so far is: click the "EN" in the taskbar, and select "JP" if the letter that appears in the taskbar is "A", hit alt-~ to change it to "?" type as if I was typing Romaji on a QWERTY keyboard, (e.g., left pinky home row, right ring finger top row), and hiragana appear (??) press spacebar to convert to kanji (e.g., ?), and return to accept That all works great, but it assumes I'm on QWERTY, which isn't very comfortable for me. I want everything the same, but to be able to type kana with Dvorak (e.g., left pinky home row, left ring finger home row - ??). I can do this on Mac OS, so it's not an unheard-of feature. But it was kind of an obscure setting to find, so I figure on Windows it's probably a really obscure setting. :-) But I haven't been able to find it yet. Thanks!

    Read the article

  • Can someone explain me implicit parameters in Scala?

    - by Oscar Reyes
    And more specifically how does the BigInt works for convert int to BigInt? In the source code it reads: ... implicit def int2bigInt(i: Int): BigInt = apply(i) ... How is this code invoked? I can understand how this other sample: "Date literals" works. In. val christmas = 24 Dec 2010 Defined by: implicit def dateLiterals(date: Int) = new { import java.util.Date def Dec(year: Int) = new Date(year, 11, date) } When int get's passed the message Dec with an int as parameter, the system looks for another method that can handle the request, in this case Dec(year:Int) Q1. Am I right in my understanding of Date literals? Q2. How does it apply to BigInt? Thanks

    Read the article

  • implicit parameter definition in class

    - by coubeatczech
    implicit val odkaz = head; def vypis(implicit odkaz:Prvek):String = { odkaz match{ case null => "" case e => e.cislo + " " + e.pocet + "\n" + vypis(e.dalsi) } } ... def main(args:Array[String]){ val q = new MyQueue() // insert some values println(q.vypis) } This method(vypis) is a member of an queue-class so I'll always want to implicity start the recursion from the start of the queue, when calling the method from outside. Is there a way how to write it, that the method from outside calling, there's no paramter, but in inside, there's a parameter - for recursion...? The compiler complains that the parameter is not defined when called from outside

    Read the article

  • Type Casting variables in PHP: Is there a practical example?

    - by Stephen
    PHP, as most of us know, has weak typing. For those who don't, PHP.net says: PHP does not require (or support) explicit type definition in variable declaration; a variable's type is determined by the context in which the variable is used. Love it or hate it, PHP re-casts variables on-the-fly. So, the following code is valid: $var = "10"; $value = 10 + $var; var_dump($value); // int(20) PHP also alows you to explicitly cast a variable, like so: $var = "10"; $value = 10 + $var; $value = (string)$value; var_dump($value); // string(2) "20" That's all cool... but, for the life of me, I cannot conceive of a practical reason for doing this. I don't have a problem with strong typing in languages that support it, like Java. That's fine, and I completely understand it. Also, I'm aware of—and fully understand the usefulness of—type hinting in function parameters. The problem I have with type casting is explained by the above quote. If PHP can swap types at-will, it can do so even after you force cast a type; and it can do so on-the-fly when you need a certain type in an operation. That makes the following valid: $var = "10"; $value = (int)$var; $value = $value . ' TaDa!'; var_dump($value); // string(8) "10 TaDa!" So what's the point? Can anyone show me a practical application or example of type casting—one that would fail if type casting were not involved? I ask this here instead of SO because I figure practicality is too subjective. Edit in response to Chris' comment Take this theoretical example of a world where user-defined type casting makes sense in PHP: You force cast variable $foo as int -- (int)$foo. You attempt to store a string value in the variable $foo. PHP throws an exception!! <--- That would make sense. Suddenly the reason for user defined type casting exists! The fact that PHP will switch things around as needed makes the point of user defined type casting vague. For example, the following two code samples are equivalent: // example 1 $foo = 0; $foo = (string)$foo; $foo = '# of Reasons for the programmer to type cast $foo as a string: ' . $foo; // example 2 $foo = 0; $foo = (int)$foo; $foo = '# of Reasons for the programmer to type cast $foo as a string: ' . $foo; UPDATE Guess who found himself using typecasting in a practical environment? Yours Truly. The requirement was to display money values on a website for a restaurant menu. The design of the site required that trailing zeros be trimmed, so that the display looked something like the following: Menu Item 1 .............. $ 4 Menu Item 2 .............. $ 7.5 Menu Item 3 .............. $ 3 The best way I found to do that wast to cast the variable as a float: $price = '7.50'; // a string from the database layer. echo 'Menu Item 2 .............. $ ' . (float)$price; PHP trims the float's trailing zeros, and then recasts the float as a string for concatenation.

    Read the article

  • howto distinguish composition and self-typing use-cases

    - by ayvango
    Scala has two instruments for expressing object composition: original self-type concept and well known trivial composition. I'm curios what situations I should use which in. There are obvious differences in their applicability. Self-type requires you to use traits. Object composition allows you to change extensions on run-time with var declaration. Leaving technical details behind I can figure two indicators to help with classification of use cases. If some object used as combinator for a complex structure such as tree or just have several similar typed parts (1 car to 4 wheels relation) than it should use composition. There is extreme opposite use case. Lets assume one trait become too big to clearly observe it and it got split. It is quite natural that you should use self-types for this case. That rules are not absolute. You may do extra work to convert code between this techniques. e.g. you may replace 4 wheels composition with self-typing over Product4. You may use Cake[T <: MyType] {part : MyType} instead of Cake { this : MyType => } for cake pattern dependencies. But both cases seem counterintuitive and give you extra work. There are plenty of boundary use cases although. One-to-one relations is very hard to decide with. Is there any simple rule to decide what kind of technique is preferable? self-type makes you classes abstract, composition makes your code verbose. self-type gives your problems with blending namespaces and also gives you extra typing for free (you got not just a cocktail of two elements but gasoline-motor oil cocktail known as a petrol bomb). How can I choose between them? What hints are there? Update: Let us discuss the following example: Adapter pattern. What benefits it has with both selt-typing and composition approaches?

    Read the article

  • Convert Option[Object] to Option[Int] Implicitly

    - by wheaties
    I'm working with legacy Java code which returns java.lang.object. I'm passing it into a function and I'd like to do some implicit conversions as such: implicit def asInt( _in:Option[Object] ) = _in asInstanceOf[ Option[Int] ] implicit def asDouble( _in:Option[Object] = _in asInstanceOf[ Option[Double] ] private def parseEntry( _name:String, _items:Map[String,Object] ) = _name match{ case docName.m_Constants => new Constants( _items get( Constants m_Epsilon ), _items get( Constant m_Rho ), _items get( Constants m_N ) ) Technically it goes on but I keep getting the same errors: expected Int, Option[Object] found. How have I done my implicits wrong? I was hoping it would do the transformation for me instead of me having to write "asInstanceOf" each and every time.

    Read the article

  • Implicit Type Conversions in Reflection

    - by bradhe
    So I've written a quick bit of code to help quickly convert between business objects and view models. Not to pimp my own blog, but you can find the details here if you're interested or need to know. One issue I've run in to is that I have a custom collection type, ProductCollection, and I need to turn that in to a string[] in on my model. Obviously, since there is no default implicit cast, I'm getting an exception in my contract converter. So, I thought I would write the next little bit of code and that should solve the problem: public static implicit operator string[](ProductCollection collection) { var list = new List<string>(); foreach (var product in collection) { if (product.Id == null) { list.Add(null); } else { list.Add(product.Id.ToString()); } } return list.ToArray(); } However, it still fails with the same cast exception. I'm wondering if it has something to do with being in reflection? If so, is there anything that I can do here?? I'm open to architectural solutions, too!

    Read the article

  • Coping with weak typing

    - by John Leonard
    I'm a front end Flex developer peeking over the wall at html. One of the things I have a hard time with is weak typing in Javascript. I know many developers say they prefer it. How do I stop worrying and learn to love the weak typing? Are there best practices for variable naming that help make var types human readable? Another thing I have trouble with is getting by without my trusted compiler errors and warnings. I'm getting along with firebug. Is there anything else I should have in my toolkit?

    Read the article

  • Scala implicit dynamic casting

    - by weakwire
    I whould like to create a scala Views helper for Android Using this combination of trait and class class ScalaView(view: View) { def onClick(action: View => Any) = view.setOnClickListener(new OnClickListener { def onClick(view: View) { action(view) } }) } trait ScalaViewTrait { implicit def view2ScalaView(view: View) = new ScalaView(view) } I'm able to write onClick() like so class MainActivity extends Activity with ScalaViewTrait { //.... val textView = new TextView(this) textView.onClick(v => v.asInstanceOf[TextView] setText ("asdas")) } My concern is that i want to avoid casting v to TextView v will always be TextView if is applied to a TextView LinearLayout if applied to LinearLayout and so on. Is there any way that v gets dynamic casted to whatever view is applied? Just started with Scala and i need your help with this. UPDATE With the help of generics the above get's like this class ScalaView[T](view: View) { def onClick(action: T => Any) = view.setOnClickListener(new OnClickListener { def onClick(view: View) { action(view.asInstanceOf[T]) } }) } trait ScalaViewTrait { implicit def view2ScalaView[T](view: View) = new ScalaView[T](view) } i can write onClick like this view2ScalaView[TextView](textView) .onClick(v => v.setText("asdas")) but is obvious that i don't have any help from explicit and i moved the problem instead or removing it

    Read the article

  • Defining implicit and explicit casts for C# interfaces

    - by ehdv
    Is there a way to write interface-based code (i.e. using interfaces rather than classes as the types accepted and passed around) in C# without giving up the use of things like implicit casts? Here's some sample code - there's been a lot removed, but these are the relevant portions. public class Game { public class VariantInfo { public string Language { get; set; } public string Variant { get; set; } } } And in ScrDictionary.cs, we have... public class ScrDictionary: IScrDictionary { public string Language { get; set; } public string Variant { get; set; } public static implicit operator Game.VariantInfo(ScrDictionary s) { return new Game.VariantInfo{Language=sd.Language, Variant=sd.Variant}; } } And the interface... public interface IScrDictionary { string Language { get; set; } string Variant { get; set; } } I want to be able to use IScrDictionary instead of ScrDictionary, but still be able to implicitly convert a ScrDictionary to a Game.VariantInfo. Also, while there may be an easy way to make this work by giving IScrDictionary a property of type Game.VariantInfo my question is more generally: Is there a way to define casts or operator overloading on interfaces? (If not, what is the proper C# way to maintain this functionality without giving up interface-oriented design?)

    Read the article

  • Matlab: Why is '1' + 1 == 50? [migrated]

    - by phi
    Matlab has weak dynamic typing, which is what causes this weird behaviour. What I do not understand is what exactly happens, as this result really surprises me. Edit: To clarify, what I'm describing is clearly a result of Matlab storing chars in ASCII-format, which was also mentioned in the comments. I'm more interested in the way Matlab handles its variables, and specifically, how and when it assigns a type/tag to the values. Thanks. '1' is a 1-by-1 matrix of chars in matlab and '123' is a 1-by-3 matrix of chars. As expected, 1 returns a 1-by-1 double. Now if I enter '1' + 1 I get 50 as a 1-by-1 double, and if I enter '123' + 1 I get a 1-by-3 double [ 50 51 52 ] Furthermore, if I type 'a' + 1 the result is 98 in a 1-by-1 double. I assume this has to do with how Matlab stores char-variables in ascii form, but how exactly is it handling these? Are the data actually unityped and tagged, or how does it work? Thanks.

    Read the article

  • How to open python scripts directly by typing in their name in terminal (Mac OS X)

    - by Haffi112
    I'm working on installing django and running it on my system. I have a problem though, in this tutorial creating a project is explained by running the command django-admin.py startproject mysite My issue is that this doesn't work. I changed to the directory where django-admin.py is located and ran the command chmod +x django-admin.py with no results. I tried adding the directory with the file to my path without results. I ended up fixing my problem with this command python /location/of/django-admin.py startproject mysite which yielded the outcome I expected. My problem is: What do I need to change/configure such that command django-admin.py startproject mysite would be sufficient? Here are some experiments: 21:09~/Desktop/HI/NSN/Polls > django-admin.py startproject mysite -bash: django-admin.py: command not found 21:09~/Desktop/HI/NSN/Polls > ./django-admin.py startproject mysite -bash: ./django-admin.py: No such file or directory 21:09~/Desktop/HI/NSN/Polls > python django-admin.py startproject mysite python: can't open file 'django-admin.py': [Errno 2] No such file or directory 21:09~/Desktop/HI/NSN/Polls > /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1 -bash: /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py: /opt/local/bin: bad interpreter: Permission denied 21:09~/Desktop/HI/NSN/Polls > sudo /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1Password: sudo: unable to execute /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py: Permission denied 21:09~/Desktop/HI/NSN/Polls > sudo /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1sudo: unable to execute /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py: Permission denied 21:09~/Desktop/HI/NSN/Polls > python /opt/local/lib/python2.4/site-packages/django/bin/django-admin.py startproject prufa1 21:09~/Desktop/HI/NSN/Polls > ls mysite prufa1 Final edit: The problem is solved, see Ian C's answer for the right solution. Thank you everyone for helping my out, this was very fast!

    Read the article

  • Typing Accent Marker in Hebrew on Mac

    - by zarose
    I'm learning ancient Hebrew and wanted to make a document full of the vocabulary words I need to memorize so that I can study during my other classes. I noticed that OSX's built-in Hebrew fonts do not include the accent marker. An example: the word for "darkness" is ??????. To represent that the accent is on the first syllable, there needs to be a < over the first letter. The accent could be in the middle of the word, so I can't just throw < at the front every time. Does anyone have a free font that includes this? Any other elegant solutions are welcome. Edit: I found that it is unicode character 05AB. Is there a way to add that to the built-in Hebrew fonts?

    Read the article

  • Trouble typing accented letters at the terminal prompt after launching Python

    - by Nicojo
    Edit: Using Mac OSX 10.6, whether I use Terminal.app or iTerm.app, when I launch Python, I can no longer type accented letters (e.g.é or ä). Any ideas? ORIGINAL POST: I am using iTerm 0.10. I would like to type in a string with accented characters (e.g. é) but when I do so at the iTerm prompt, no character appears. This does not occur in Terminal. Could someone help me find out what the problem is, and eventually fix it? EDIT: In Terminal.app, I can use accented characters. However, when I launch the Python 2.71 prompt, I can no longer type in accented characters. When I quit python and return to the terminal prompt, I can again type accented characters. In iTerm, although I quit Python and restarted iTerm, I cannot type in accented characters (I do not know if I could before).

    Read the article

  • Typing with a right-to-left language on Windows Vista Home Premium (English)

    - by pablo
    A friend's laptop came with "Windows Vista Home Premium (SP1)" installed in English. But she's from a country with a right-to-left language, and she wants to be able to type in her own language from right-to-left. Going to the control panel and adding a keyboard on her language did half of the trick. She can type in her language but on a left-to-right way. Is it possible to enable the cursor to go on the other direction?

    Read the article

  • Running programs by typing some alias in Windows

    - by devoured elysium
    Is there an easy way in windows to set a given string, like "sidb" to run a program or open a given folder in Windows? My original idea was to be able to run commands like that in the "Execute" start button menu (or Win + R),so I'd just have to do WIN+R and type "sidb". What is the best way to accomplish this? EDIT: May I rephrase this as : Is there a way to define for example, in systems variables, sibd="C:.......blabla\ and then I'd just have to type "sibd" in Run?

    Read the article

  • Running programs by typing some alias in Windows

    - by devoured elysium
    Is there an easy way in windows to set a given string, like "sidb" to run a program or open a given folder in Windows? My original idea was to be able to run commands like that in the "Execute" start button menu (or Win + R),so I'd just have to do WIN+R and type "sidb". What is the best way to accomplish this? EDIT: May I rephrase this as : Is there a way to define for example, in systems variables, sibd="C:.......blabla\ and then I'd just have to type "sibd" in Run?

    Read the article

  • UIVideoAtPathIsCompatibleWithSavedPhotosAlbum generates error implicit declaration of function, why?

    - by just_another_coder
    In my project I am trying to save video to the iPhone after being taken by the camera. When I call the method: UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(path) It reports the error: Implicit declaration of function 'UIVideoAtPathIsCompatibleWithSavedPhotosAlbum' I've imported MobileCoreServices/UTCoreTypes.h I was previously using this same code for saving camera pictures, and it worked fine. In another class, in the same project, I am able to reference the UIKit method: UIImagePNGRepresentation() without any problems So why does it give me this error?

    Read the article

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