本稿ではNim言語 (旧称: Nimrod) の構文を紹介します。
Nim言語の概要やインストール方法については、ブログ記事があるのでそちらをご参照下さい。
| import os, asyncnet, asyncdispatch | |
| proc callback1(): Future[int] = | |
| var retFuture = newFuture[int]("callback1") | |
| echo "Callback1: Waiting" | |
| sleep(3000) | |
| retFuture.complete(10) | |
| return retFuture |
| # USAGE | |
| # 1. Add 'factory_girl' in Gemfile as a dependency. But here, be careful. Factory Girl adds Active Support | |
| # as its dependency, so it is up to you add it in :development and :test group or add it for all envs. | |
| # For more details, read the comment from @cllns below. | |
| # 2. Save this file in '/spec'; | |
| # 3. Load this file in 'spec_helper.rb' as the last require in the file, using: | |
| # require_relative './factory_girl_helper' |
| { | |
| "jest": { | |
| "moduleFileExtensions": [ | |
| "js", | |
| "json", | |
| "jsx", | |
| "node", | |
| "coffee" | |
| ], | |
| "preprocessorIgnorePatterns": [ ], |
本稿ではNim言語 (旧称: Nimrod) の構文を紹介します。
Nim言語の概要やインストール方法については、ブログ記事があるのでそちらをご参照下さい。
| module AlertConfirmer | |
| class << self | |
| def reject_confirm_from &block | |
| handle_js_modal 'confirm', false, &block | |
| end | |
| def accept_confirm_from &block | |
| handle_js_modal 'confirm', true, &block | |
| end |
| require 'rubygems' | |
| require 'rubygems/dependency_installer' | |
| require 'json' | |
| require 'open-uri' | |
| class GemVersions | |
| def initialize(gem) | |
| @gem = gem | |
| @versions = JSON.parse( |
| // do not use result cache, nor line and column tracking | |
| { var indentStack = [], indent = ""; } | |
| start | |
| = INDENT? lines:( blank / line )* | |
| { return lines; } | |
| line | |
| = SAMEDENT line:(!EOL c:. { return c; })+ EOL? |