option

Int Option instead of Int in F#

我的梦境 提交于 2019-12-11 05:59:56
问题 I am having trouble with the following: let safeDiv x y = match (x,y) with | (_, Some 0) -> None | (Some xx, Some yy) -> Some (xx/yy) | _ -> None When I go to run this simple function in the interactive window of Visual Studio like so: safeDiv 4 2 I get the following error... This expression was expected to have type int option but here has type int. Could it be I'm meant to use safeDiv Some(4) Some(2) ? This doesn't work either... 回答1: Ok, this is overkill but I actually did something

Javascript to change colors onChange options

我怕爱的太早我们不能终老 提交于 2019-12-11 05:55:53
问题 I'm back with another one -_-. currently my page has buttons to change the color of my Philip's hue lights -- but I want it to be a dropdown that will change as I change the option. Here's what the current buttons look like: <button class="lightbuttontall" onclick="lightcolor(1,colorred);">Light 1 red</button> <button class="lightbuttontall" onclick="lightcolor(2,colorred);">Light 2 red</button> <button class="lightbuttontall" onclick="lightcolor(3,colorred);">Light 3 red</button> </p> <p

Scala Option map to another Option

我怕爱的太早我们不能终老 提交于 2019-12-11 04:55:03
问题 Is there a way to avoid having to wrap a potentially null result inside another option when mapping from an option. option.flatMap(arg => Option(arg.somePotentiallyNullValue)) Eg something like option.optionMap(arg => arg.somePotentiallyNullValue ) I just have a lot of Java code in our codebase that means forever wrapping the results of maps in further Option calls. 回答1: What about implicit conversion from nullable type to Option ? Declare this somewhere in scope: implicit def toOption[T](x:

scala Option type difference

女生的网名这么多〃 提交于 2019-12-11 04:14:58
问题 What is the difference between passing two arguments vs passing one argument? val option1 = Option(String,String) and val option2 = Option(String) 回答1: When you write something like Option(1, 2) , the compiler first desugars this to Option.apply(1, 2) , and then when it sees that the Option companion object doesn't have an apply method that takes two arguments, it automatically converts the arguments into a tuple: scala> Option(1, 2) res0: Option[(Int, Int)] = Some((1,2)) It would do

how to display an option menu when an activity starts

爱⌒轻易说出口 提交于 2019-12-11 02:33:24
问题 I've activity that i want an option menu to be displayed on. But, i want the option menu to be displayed all the time the activity is displayed. I don't want my users to click (select) the menu button to display it. I want it to be there all the time. How can i do it? thanks 回答1: Activity.openOptionsMenu() . From a design standpoint, I have to agree with Mayra. Wrong approach to begin with. 回答2: If you want options to appear at the bottom of the screen always, don't use the options menu. Just

Java populating <option> dropdown list

夙愿已清 提交于 2019-12-11 02:00:37
问题 I have the following code: <div> <% TaxonomicTypeFeed ttf = new TaxonomicTypeFeed(); ArrayList<String> tmp = ttf.getTypes(); System.out.println("Going to print"); for (int i=0; i < tmp.size(); i++) { System.out.println(tmp.get(i)); } %> <form> <select> <% Iterator<String> i = tmp.iterator(); while (i.hasNext()) { String str = i.next(); %> <option value="<%str.toString();%>"><%str.toString();%> </option> <%}%> </select> </form> </div> It creates a dropdown list fine, however there is no text.

Style the font for <select> and <option> tags in FireFox / Mozilla

可紊 提交于 2019-12-11 01:54:07
问题 The font between the <option> tags cannot be changed with CSS in FireFox. (It can be done, using normal CSS statements, in Chrome.) I can change the font for the <select> part of the statement using CSS, so that the selected option appears in my desired font, but the text between the <option> tags in the dropdown list are always in FireFox's default font. This is important because I want to use a monospace font in the option tags. Can I gain control over style of the font in the <option> tag

Is there an easy way to create a C# .NET file dialog with encoding dialog box?

a 夏天 提交于 2019-12-11 01:44:43
问题 I'm trying to let the user select the file encoding when they load or save a file in C# and VS2008. Notepad's dialog boxes have an encoding drop down option at the bottom. There is a way to do it as described in here: http://www.codeproject.com/KB/cs/getsavefilename.aspx. However, I'm wondering if there is any easier way to do this. Windows must have this dialog built-in somewhere, isn't it? 回答1: The dialog that is built in is the standard File Open dialog provided by the Win32 API. This

How can I apply table structure to select box options in HTML

末鹿安然 提交于 2019-12-11 00:18:54
问题 In my select box options, each option having three words.Now I want apply fixed widths for each word of the option so that the all options will come as i required for example My options are as follows : 1, aaaaa bbbbb ccccccccc 2, aaaaaaaa bbbbbbb cccc 3, aaaaaa bbbbb cccc but i want to display these options in the dropdown as 1, aaaaa bbbbb ccccccccc 2, aaaaaaaa bbbbbbb cccc 3, aaaaaa bbbbb cccc help me if anyone know how to do this 回答1: you can use div and CSS style .See this sample that i

Option-izing Java getters

旧城冷巷雨未停 提交于 2019-12-10 21:19:13
问题 When working with Java from Scala, we have to account for null. HttpServletRequest getters (getAttribute, getHeader, etc.) for example, all potentially return null. I know I can manually do a case/match or map operation on each call to an HttpServletRequest method, but that's a bit tedious. Also, method calls like request.getHeader("Accept-Encoding") are a mouthful. I came up with an enrichment to handle both issues: class Servlet_Request_Provides_NullSafe_Getters (r: HttpServletRequest) {