码迷,mamicode.com
首页 >  
搜索关键字:def    ( 28626个结果
Scala中的Apply
/** * Created by Administrator on 2014-12-31. */class ApplyTest { def apply() = "Apply customer" def test(): Unit = { println("test") }}object A...
分类:移动开发   时间:2014-12-31 07:37:11    阅读次数:162
scala中的implict
1.作为隐式参数 1 object Test { 2 3 def main(args: Array[String]) { 4 import FruitColor._ 5 Fruit.get("apple") 6 } 7 } 8 9 object Fruit{10 de...
分类:其他好文   时间:2014-12-30 23:26:37    阅读次数:254
scala中的view bound与context bound
1.scala中的Int): Unit ={ }}View Code其中的Function1的定义如下2.与view bounds一样context bounds(上下文界定)也是隐式参数的语法糖object Test { def main(args: Array[String]) { } ...
分类:其他好文   时间:2014-12-30 23:17:04    阅读次数:744
scala编程第18章学习笔记——有状态的对象
银行账号的简化实现:scala> class BankAccount{ | private var bal: Int = 0 | def balance: Int = bal | def deposit(amount: Int) { | require(amount ...
分类:其他好文   时间:2014-12-30 22:06:12    阅读次数:149
一个用户统计函数调用事件的装饰器
装饰器前面提过了,采用python的闭包特性实现: from time import time from time import sleep def count_time(): def tmp(func): def wrapped(*args, **kargs): begin_time = time...
分类:其他好文   时间:2014-12-30 22:01:11    阅读次数:151
使用pymysql插入语句时对execute与executemany两个方法进行测速
这两天,在写一个python小程序的时候突然大发奇想了一下,觉得可以测试一下pymysql包里面的execute()与executemany()的速度,executemany()实质上就是将数组中的元素一个个取出来然后一条条的执行,可以查看executemany()的源码为: def executemany(self, query, args): """Run several...
分类:数据库   时间:2014-12-30 20:47:07    阅读次数:908
python多线程(等待)主线程和子线程的同步执行
#!/usr/bin/env python # -*- coding: utf-8 -*- import threading import time def fun(name, ls_name, front_thread = None):     '''     线程启动函数     通过front_thread来使用线程有序的运行     '''     time.cloc...
分类:编程语言   时间:2014-12-30 15:20:06    阅读次数:311
Ruby学习-第二章
第二章类继承,属性,类变量1.如何声明一个子类class Treasure [:a] //只有aclass A def b puts 'b' endenda.public_methods(false)# => [:a, :b]//有a和b而不能修改的,是类继承了哪个类。比如class A...
分类:其他好文   时间:2014-12-30 13:13:36    阅读次数:192
Python菜鸟学习手册06----函数
1.简介          函数是重用的程序段。它们允许你给一块语句一个名称,然后你可以在你的程序的任何地方使用这个名称任意多次地运行这个语句块。这被称为调用函数。我们已经使用了许多内建的函数,比如input()和range()。 2.函数的定义和调用        函数通过def关键字定义。def关键字后跟一个函数的标识符名称,然后跟一对圆括号。圆括号之中可以包括一些变量名,该行以冒号结尾...
分类:编程语言   时间:2014-12-30 11:46:12    阅读次数:144
python 学习笔记-构造方法
Python中的构造函数是形如def__init__(self),例如classBird: def__init__(self): self.hungry=True defeat(self): ifself.hungry: print‘Ahhhh‘ self.hungry=False else: print‘no,thx‘ 实例化类Bird对象b: b=Bird() b.eat() b.eat() Ahhhh no,thx假设现在Bird有一个子类So..
分类:编程语言   时间:2014-12-30 09:20:32    阅读次数:166
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!