You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');| source 'https://rubygems.org' | |
| # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' | |
| gem 'rails', '4.2.6' | |
| # Use sqlite3 as the database for Active Record | |
| gem 'sqlite3' | |
| # Use ActiveModel has_secure_password | |
| # gem 'bcrypt', '~> 3.1.7' |
| <?php | |
| /** | |
| * Kelas untuk memanipulasi data yang berkaitan dengan rupiah. | |
| * | |
| * Catatan: Saya lupa darimana contoh fungsi terbilang awalnya! | |
| * | |
| * @version 0.0.1 | |
| * @author Anggiajuang Patria <[email protected]> | |
| * @copyright (c) 2009-2010 http://www.segellabs.com/ | |
| * @license http://www.gnu.org/licenses/gpl-3.0.txt |
| 'Once upon a time in a world far far away'.truncate(20, separator: /\s/) | |
| # "Once upon a time..." |
| def validate_date date | |
| begin | |
| Date.parse(date) | |
| rescue ArgumentError | |
| Date.today | |
| end | |
| end |
You know how, in JavaScript, we can set a value to a variable if one doesn't, like this:
name = name || 'joe';This is quite common and very helpful. Another option is to do:
name || (name = 'joe');| var gulp = require('gulp'), | |
| concat = require('gulp-concat'), | |
| prefix = require('gulp-autoprefixer'), | |
| sass = require('gulp-sass') | |
| cleancss = require('gulp-clean-css'), | |
| uglify = require('gulp-uglify'), | |
| rename = require('gulp-rename'), | |
| notify = require('gulp-notify'); | |
| var cssDir = 'public/assets/css', |