通过Groovy中的地图循环?(Loop through Map in Groovy?)
我有一个非常简单的任务,我想在Groovy做,但似乎无法让它工作。 我只是试图在groovy中循环遍历一个map对象,并打印出关键字和值,但是这个代码不起作用。
//A simple map def map = [ 'iPhone':'iWebOS', 'Android':'2.3.3', 'Nokia':'Symbian', 'Windows':'WM8' ] //Print the values for(s in map) { println s + ":" + map[s] }
我试图让输出看起来像这样:
iPhone:iWebOS Android:2.3.3 Nokia:Symbian Windows:WM8
有人请详细说明如何做到这一点吗?
I have a very simple task I am trying to do in Groovy but cannot seem to get it to work. I am just trying to loop through a map object in groovy and print out the key and value but this code does not work.
// A simple map def map = [ iPhone : 'iWebOS', Android: '2.3.3', Nokia : 'Symbian', Windows: 'WM8' ] // Print the values for (s in map) { println s + ": " + map[s] }
I am trying to get the output to look like this:
iPhone: iWebOS Android: 2.3.3 Nokia: Symbian Windows: WM8
Could someone please elaborate on how to do this??
原文:https://stackoverflow.com/questions/10037374
更新时间:2022-03-17 19:03
相关问答
更多-
如何使用jQuery选择具有特定ARIA值的所有元素?(How to select all elements with particular ARIA value using jQuery?)[2023-07-12]
属性选择器 [aria-controls="name1"] 应该管用。 文档: http : //api.jquery.com/attribute-equals-selector/ The attribute selector [aria-controls="name1"] should work. Docs: http://api.jquery.com/attribute-equals-selector/ -
我称这些单页面应用程序为“长寿”应用程序。 对于“简单的应用程序”来说,这很糟糕。 突然间为浏览器提供OOTB的东西需要特别的关注和关注: 后退按钮 刷新按钮 书签/复制网址 注意我并不是说你不能用单页面应用程序做这些事情,我说你需要努力将它们构建到应用程序代码中。 如果您只是在不同的网站上拥有不同的资源,这些工作无需额外的开发人员。 现在,对于复杂的应用程序,如Gmail,谷歌地图,其好处是: 应用程序的用户感知响应可以增加 应用程序的可用性可能会上升(例如,当点击用户认为是一个小动作时,滚动条不会跳到新 ...
-
AngularJS非常适合单页应用程序的含义是什么?(AngularJS is perfect for Single Page Applications what is the meaning?)[2023-07-23]
SPA是单页面应用程序,浏览器在此处加载整个页面一次,并根据用户在交互期间的请求刷新页面的一部分。 现在我们来看看AngularJS的优势, 双向数据绑定:当数据更改时,视图自动刷新,这意味着我们不需要再次加载整个页面。 控制器:您可以使用控制器将您的逻辑仅限制在视图的特定部分。 这使得视图范围仅涉及特定的控制器。 这是brillinat控制SPA的方式。 服务:这些是在应用程序加载时仅实例化一次的单例对象。 指令:指令是自定义小部件。 我们创造它们一次并在我们需要的地方使用它们。 路由:根据用户请求切换视 ... -
如果我已经正确地理解了你的问题,那么你的ng-include(d)离散的功能块就像是作为指令实现的理想候选者。 您的路由提供程序配置允许您通过在使用templateUrl参数传入的对象中指定控制器参数来为多个页面加载相同的控制器。 这允许您在多个部分共享相同的控制器,并使您的页面可组合,只要您可以根据您所服务的路线将部分与控制器混合和匹配。 然而,这确实意味着,正如您所观察到的那样,您的控制器脚本需要在启动时加载,即不是动态加载,但这是角度解决方案的默认/标准架构方法。 如果你想动态加载你的控制器,那么你需 ...
-
ARIA Properties,DOM和Graceful Degradation(ARIA Properties, DOM, and Graceful Degradation)[2024-04-29]
ARIA Landmark角色可以直接放入标记中,即使禁用JavaScript也可以使用它们。 如果ARIA属性描述的功能仅在启用JavaScript时可用,我会说可以使用JavaScript添加这些属性。 ARIA Landmark roles are OK to put directly in the markup, they can be beneficial even when JavaScript is disabled. If the functionality the ARIA attribu ... -
在开发服务器上,您只需为不以api/或static/开头的所有内容设置路由,以返回基本的app.html文件。 例 class AppHTMLView(View): def get(self, request): fn = os.path.join(settings.BASE_DIR, "app", "app.html") with open(fn, 'r') as fh: return HttpResponse(fh.read()) 在生 ...
-
你的问题有一个简短的答案和一个很长的答案,让我们看看那些是什么? Angular 2和4是否有任何等效模块在运行时静默地在组件上注入aria属性? 我们首先引用AngularJs的KB: 使用ngAria就像在您的应用程序中需要ngAria模块一样简单。 ngAria挂钩到标准的AngularJS指令,并在运行时静默地向您的应用程序注入可访问性支持。 由于Angular 2试图对ARIA提供内置支持,因此不需要这样的等效模块,也没有我所知道的补充模块。 所以,是的,它是隐含支持的,不,没有这样的模块(必需) ...
-
是的,如果您的意思是使用KnockoutJS和UpshotJS演示的SPA概念,它确实需要EF。 这是因为Upshot旨在使用EF提供的元数据。 但是,现在还处于早期阶段,我们不知道Upshot将来会提供哪些功能。 我们甚至可能会看到Upshot的客户端库或扩展来处理不同的dbs。 关于SPA作为一个概念,您现在可以使用ASP.NET MVC,KnockoutJS / BackboneJS和常规JQuery ajax调用来实现它。 Yes it does require EF if you mean the ...
-
当从DOM添加或删除带有aria-live (或带有aria-live的元素中的文本)的元素时, aria-live会触发屏幕阅读器。 相反,当您取消隐藏隐藏元素时,既不会添加元素也不会从DOM中删除元素,因此元素的aria-live属性不起作用。 为了让屏幕阅读器宣布“不要刷新页面”,这些选项中的任何一个都可以做到这一点: 您可以从头开始创建元素及其文本内容,然后将该元素添加到DOM中。 或者你可以从空的我相信所选择的咏叹调是用于“小部件”的单一制表位,就像一组标签,然后你可以选择它。 选定的方面是关于哪一个是焦点 , 而不是您所在的页面。 我会看看这是一个经过充分测试的例子: http : //whatsock.com/tsg/Coding%20Arena/ARIA%20Menus/Horizontal%20(Internal%20Content)/demo.htm 来自: http : //whatsock.com/tsg/ 为了显示当前页面,我可能会使用更传统的方法:使它不是链接。 例如:
- < ...
相关文章
更多- Groovy 循环语句
- Spring4新特性——Groovy Bean定义DSL
- Gradle构建Groovy项目
- Groovy 环境配置
- Groovy 快速入门程序
- Groovy 数字类型
- Groovy def可选类型
- Groovy 变量详解
- Groovy 方法详解
- Groovy 条件语句
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)