| class UserController extends Controller | |
| { | |
| private const USER_PATH = "/tmp/users.csv"; | |
| /* | |
| * $user_idに対応するユーザデータをjsonで返す | |
| */ | |
| public function show(int $user_id) | |
| { | |
| $user = null; // ここで作成したクラスのメソッドを呼ぶ |
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| public class HogeListView extends ListView { | |
| public HogeListView(Context context) { | |
| super(context); | |
| } | |
| public HogeListView(Context context, AttributeSet attrs) { | |
| super(context, attrs); | |
| } |
| String json = "{id:3, age:30, first_name: 'hoge', last_name: 'fuga'}"; | |
| Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); | |
| User user = gson.fromJson(json, User.class); |
| package com.example.android; | |
| import com.example.android.R; | |
| import android.content.Context; | |
| import android.support.v4.view.ActionProvider; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.View.OnClickListener; | |
| import android.widget.TextView; |
| >>> def func_dict(**argv): | |
| ... print 'dict ----' | |
| ... print argv | |
| ... | |
| >>> | |
| >>> d = {'a': 1, 'b': True, 'c': u'ほげ'} | |
| >>> | |
| >>> func_dict(d) | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> |
| >>> def func_tuple(*argv): | |
| ... print 'tuple ----' | |
| ... print argv | |
| ... | |
| >>> | |
| >>> t = (1, True, 'A') | |
| >>> | |
| >>> func_tuple(t) | |
| tuple ---- | |
| ((1, True, 'A'),) |
| >>> def test(*argv): | |
| ... hoge(argv) | |
| ... fuga(*argv) | |
| ... | |
| >>> def hoge(*argv): | |
| ... print argv | |
| ... | |
| >>> def fuga(*argv): | |
| ... print argv | |
| ... |
| # 可変長引数(tuple) | |
| >>> def func(*v): | |
| ... print v | |
| ... | |
| >>> func(1) | |
| (1,) | |
| >>> func(1, "ABC", True) | |
| (1, 'ABC', True) | |
| # 可変長引数(dict) |
| # 連結 | |
| >>> a = [1, 2, 3] | |
| >>> b = [4, 6, 6] | |
| >>> a + b | |
| [1, 2, 3, 4, 6, 6] | |
| # 重複の削除 | |
| >>> a = [100, 20, 5, 10, 5, 20, 8] | |
| >>> list(set(a)) | |
| [8, 20, 10, 100, 5] |
NewerOlder